C# .NET: Get List of Enum Values

11/25/2013 10:55:18 PM

.NET Framework

The following will create a List<> of all values for a certain type of enum.

public static IEnumerable<T> List_EnumValues<T>()
{
	return Enum.GetValues(typeof(T)).Cast<T>();
}

//use of
List<SomeEnum> enumValues = List_EnumValues<SomeEnum>().ToList();