EnumerableExt.RandomElement(TIn) Method

Returns a random element from the collection.

Namespace: UltimateXR.Extensions.System.Collections
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0

Syntax

C#

public static TIn RandomElement<TIn>(
	this IEnumerable<TIn> list
)

Parameters

 

list
Type: System.Collections.Generic.IEnumerable(TIn)
Collection to get the random element from

Type Parameters

 

TIn
Element type

Return Value

Type: TIn
Random element from the collection

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(TIn). 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).

Remarks

Uses Unity’s random number generator (Range(Int32, Int32)).

See Also

Reference

EnumerableExt Class
UltimateXR.Extensions.System.Collections Namespace