 | EnumerableExtensionMethodsRandomSelectT Method (IEnumerableT, Int32) |
Selects the specified number of random items from the specified enumerable.
If the number of items in the enumerable is smaller than the specified number of selections,
the enumerable itself is returned.
Namespace: Slash.Collections.ExtensionsAssembly: Slash.Collections (in Slash.Collections.dll) Version: 1.0.6018.40177
Syntaxpublic static IEnumerable<T> RandomSelect<T>(
this IEnumerable<T> enumerable,
int numberOfSelections
)
<ExtensionAttribute>
Public Shared Function RandomSelect(Of T) (
enumerable As IEnumerable(Of T),
numberOfSelections As Integer
) As IEnumerable(Of T)
public:
[ExtensionAttribute]
generic<typename T>
static IEnumerable<T>^ RandomSelect(
IEnumerable<T>^ enumerable,
int numberOfSelections
)
[<ExtensionAttribute>]
static member RandomSelect :
enumerable : IEnumerable<'T> *
numberOfSelections : int -> IEnumerable<'T>
Parameters
- enumerable
- Type: System.Collections.GenericIEnumerableT
Enumerable to get random items from. - numberOfSelections
- Type: SystemInt32
Number of items to get from the enumerable.
Type Parameters
- T
- Type of items in enumerable.
Return Value
Type:
IEnumerableT Random items from specified enumerable.
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).
Exceptions
See Also