I want to count the number. How can I get the number of items defined in an enum?
enum MyEnum
{
A = 1,
B = 2,
C = 1,
D = 3,
E = 2
}
I want to count the number. How can I get the number of items defined in an enum?
enum MyEnum
{
A = 1,
B = 2,
C = 1,
D = 3,
E = 2
}
For this You can use the static method Enum.GetNames
var myEnumMemberCount = Enum.GetNames(typeof(MyEnum)).Length;