How can I get the number of items defined in an enum?
You can use the static method Enum.GetNames which returns an array representing the names of all the items in the enum. The length property of this array equals the number of items defined in the enum
Enum.GetNames
var myEnumMemberCount = Enum.GetNames(typeof(MyEnum)).Length;
1.4m articles
1.4m replys
5 comments
57.0k users