1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:58:49 +00:00

🔨 Call OneOf() overload to reduce duplication

This commit is contained in:
Oliver Booth 2019-11-16 11:02:20 +00:00
parent 8c39914547
commit ae4f7f7b38
No known key found for this signature in database
GPG Key ID: 4B0992B2602C3778

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
#endregion #endregion
@ -28,7 +29,7 @@
/// <param name="source">The collection to draw from.</param> /// <param name="source">The collection to draw from.</param>
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns> /// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
public static T OneOf<T>(this Random random, params T[] source) => public static T OneOf<T>(this Random random, params T[] source) =>
source[random.Next(source.Length)]; source.ToList().OneOf(random);
/// <summary> /// <summary>
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance. /// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.