Click or drag to resize

ListExtensionsGetRandomT Method

Returns a random element from a list or array.

Namespace:  Kit
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0
Syntax
C#
public static T GetRandom<T>(
	this IReadOnlyList<T> list
)
where T : class
Request Example View Source

Parameters

list
Type: System.Collections.GenericIReadOnlyListT

Type Parameters

T

Return Value

Type: T
A random element, or if the list is empty.

Usage Note

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