/// <summary> /// Returns a random element of a sequence of elements, or a default value if no element is found. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The <see cref="IEnumerable{T}"/> to return a random element of.</param> /// <param name="randomizer">The function delegate that will select a random element of <paramref name="source"/>.</param> /// <returns>default(TSource) if source is empty; otherwise, a random element of <paramref name="source"/>.</returns> public static TSource RandomOrDefault <TSource>(this IEnumerable <TSource> source, Func <IEnumerable <TSource>, TSource> randomizer) { return(EnumerableUtility.RandomOrDefault(source, randomizer)); }
/// <summary> /// Returns a random element of a sequence of elements, or a default value if no element is found. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The <see cref="IEnumerable{T}"/> to return a random element of.</param> /// <returns>default(TSource) if source is empty; otherwise, a random element of <paramref name="source"/>.</returns> public static TSource RandomOrDefault <TSource>(this IEnumerable <TSource> source) { return(EnumerableUtility.RandomOrDefault(source)); }