Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: T PickRandom<T>(this IEnumerable<T>, Random)

Declaration

public static T PickRandom<T>(
    this IEnumerable<T> src,
    Random rnd = null
)

Summary

Returns a random element from the specified collection.

Generic type parameters

T The type of the elements in the collection.

Parameters

this IEnumerable<T>src The collection to pick from.
Randomrnd Optionally, a random number generator to use.

Returns

The element randomly picked.

Remarks

This method enumerates the entire input sequence into an array.