Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# random enum

public T RandomEnum<T>(T obj)
{
	List<T> enums = Enum.GetValues(typeof(T)).Cast<T>().ToList();
	System.Random random = new System.Random();

	return enums[random.Next(0, enums.Count)];
}
 
PREVIOUS NEXT
Tagged: #random #enum
ADD COMMENT
Topic
Name
2+5 =