当前位置: 编程技术>.net/c#/asp.net
C# 获取枚举值的简单实例
来源: 互联网 发布时间:2014-10-23
本文导语: 先申明一个枚举: 代码如下: public enum Test_Enum { one = 1001, two = 1002, three = 1003, four = 1004, five = 1005, six = 1006, seven = 1007, eight = 1008, nine = 1009, zero = 1000 }获取值: 代码如下: object ojb = Enum.GetNa...
先申明一个枚举:
代码如下:
public enum Test_Enum
{
one = 1001, two = 1002, three = 1003, four = 1004, five = 1005, six = 1006, seven = 1007, eight = 1008, nine = 1009, zero = 1000
}
获取值:
代码如下:
object ojb = Enum.GetName(typeof(Test_Enum),Test_Enum.eight);
int i = (int)Test_Enum.eight;