RandomOrDefault Method
Definition
- Namespace
- Cuemon.Extensions.Collections.Generic
- Assemblies
- Cuemon.Extensions.Collections.Generic.dll
RandomOrDefault<T>(IEnumerable<T>)
Returns a random element of a sequence of elements, or a default value if no element is found.
public static T RandomOrDefault<T>(this IEnumerable<T> source)
Parameters
sourceIEnumerable<T>An IEnumerable<T> to extend.
Returns
- T
defaultifsourceis empty; otherwise, a random element ofsource.
Type Parameters
TThe type of the elements of
source.