ListExt.RandomElement<T> Method

Returns a random element from the list.

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

Syntax

C#

public static T RandomElement<T>(
	this IReadOnlyList<T> self
)

Parameters

 

self
Type: System.Collections.Generic.IReadOnlyList<T>
List to get the random element from

Type Parameters

 

T
Element type

Return Value

Type: T
Random element from the list

Usage Note

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

ListExt Class
UltimateXR.Extensions.System.Collections Namespace