How to get the items count of an enum

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I have declare a enum in my program, like:
public enum enAllow { SchoolID , PW , Kind , SchYears , GradeID , Ver , IP,
Msg};

How can I get the items count of this enum?
 
Use either Enum.GetNames or Enum.GetValues method.
Example:

int count = Enum.GetValues(typeof(enAllow)).Length;
 
Back
Top