Total number of items defined in an enum C# Anonymous User 1050 02-Apr-2018 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 } c# c# Updated on 02-Apr-2018
Anonymous User
02-Apr-2018For this You can use the static method Enum.GetNames
var myEnumMemberCount = Enum.GetNames(typeof(MyEnum)).Length;