......
enum orientation : int
{
north = 1111,
north1 = 3333,
north2 = 4444
}
......
我想将north变成2应该怎么写呢?
orientation sdf;
sdf.north = 2;//错误
orientation.north = 2;//错误
这两种方法都不好用,应该怎么写呢?
enum orientation : int
{
north = 1111,
north1 = 3333,
north2 = 4444
}
......
我想将north变成2应该怎么写呢?
orientation sdf;
sdf.north = 2;//错误
orientation.north = 2;//错误
这两种方法都不好用,应该怎么写呢?
north = 1111,
north1 = 3333,
north2 = 4444
}
......其实没必要显式继承int结构,在C#里enum你可以理解为除char 以外的特殊整型
用的时候直接转换
int north = (int)orientation.north;另外Enum类下面有很多有用的方法 MSDN
枚举类型只能在定义的时候指定值,否则默认从零开始,依此累加