首页  编辑  

遍历枚举类型的元素

Tags: /C#/RTTI/   Date Created:

enum MyEnum

{

   a = 1 ,

   b = 2 ,

   c = 3 ,

}

foreach ( string vName in Enum . GetNames( typeof ( MyEnum )))

    Console . WriteLine(vName);

foreach ( int vValue in Enum . GetValues( typeof ( MyEnum )))

    Console . WriteLine(vValue);