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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

about enum 3
Enum TypeConverter 3
Merge Info From Two Enums 1
enum type 3
Enums & Constructors? 4
Enum Extentions 7
is it possible to receive enum as argument to method 6
Arrays of List collections 4

Back
Top