1

I have an enum as below:

public enum DatabaseCommand
{
     [Category("Connection")]
     Connected= 0,
     [Category("Connection")]
     Disconnected,
     [Category("Connection")]
     GetConnectionStatus,
     [Category("Execute")]
     ExecuteSQLString,
     [Category("Execute")]
     ExecuteSQLStoreProcedure,
     CustomCommand,
}

So, how can I list all of Category Attribute by passing typeof(DatabaseCommand) and return a array of string as below:

"Connection" , "Execute" and "".

Any help? Thank you!!!

Tan Le
  • 57
  • 1
  • 8
  • Possible duplicate of http://stackoverflow.com/questions/12022557/get-a-liststring-of-my-enum-attributes-with-a-generic-method – Adil Apr 15 '14 at 10:26
  • Not the same, but take a look at this: http://stackoverflow.com/questions/2650080/how-to-get-c-sharp-enum-description-from-value – Nahuel Ianni Apr 15 '14 at 10:33
  • Thank you all, I had modified some code and it work for me. – Tan Le Apr 15 '14 at 10:49

0 Answers0