......       
 enum orientation : int
        {
            north = 1111,
            north1 = 3333,
            north2 = 4444
        }
......
我想将north变成2应该怎么写呢?
orientation sdf;
sdf.north = 2;//错误
orientation.north = 2;//错误
这两种方法都不好用,应该怎么写呢?

解决方案 »

  1.   

    http://topic.csdn.net/u/20090814/22/b2fa8fca-c2e8-4be0-9ba1-5ef467078eb1.html
      

  2.   

    enum orientation : int  {
      north = 1111,
      north1 = 3333,
      north2 = 4444
      }
    ......其实没必要显式继承int结构,在C#里enum你可以理解为除char 以外的特殊整型
    用的时候直接转换
    int north = (int)orientation.north;另外Enum类下面有很多有用的方法 MSDN
      

  3.   

    http://msdn.microsoft.com/zh-cn/library/sbbt4032(v=vs.80).aspx
    枚举类型只能在定义的时候指定值,否则默认从零开始,依此累加