Click or drag to resize

IEnumerableExtensionsSelectRandomT Method

Selects one or more randomly selected items from an enumeration.

Namespace:  System.Collections.Generic
Assembly:  Neon.Common (in Neon.Common.dll) Version: 2.14.0
public static IEnumerable<T> SelectRandom<T>(
	this IEnumerable<T> items,
	int count = 1


Type: System.Collections.GenericIEnumerableT
The source items.
count (Optional)
Type: SystemInt32
The number of values to be returned (defaults to 1.

Type Parameters

The value type.

Return Value

Type: IEnumerableT
The randomly selected items as an enumeration.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
ArgumentException Thrown if count is not positive or if items does not have at least count items.
See Also