获取枚举中所有类别属性的列表?

时间:2014-04-15 10:25:33

标签: c# arrays string reflection enums

我有一个枚举如下:

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

那么,如何通过传递typeof(DatabaseCommand)列出所有类别属性并返回一个字符串数组,如下所示:

"Connection" , "Execute" and "".

有任何帮助吗? 谢谢!!!

0 个答案:

没有答案