C#编程(4_复杂的变量类型)

2020-12-13 13:59

阅读:337

标签:style   blog   color   io   os   ar   sp   div   on   

  • 枚举类型
enum
{
,
,
,
,
...
,
}

举例:

namespace ConsoleApplication1
{
    enum orientation : byte
    { 
        north=1,
        south=2,
        east=3,
        west=4,
    }
    class Program
    {
        static void Main(string[] args)
        {
            byte directionByte;
            string directionString;
            orientation myDirection = orientation.north;
            Console.WriteLine("myDirection={0}",myDirection);
            directionByte = (byte)myDirection;
            directionString = Convert.ToString(myDirection);
            Console.WriteLine("byte equivalent={0}",directionByte);
            Console.WriteLine("string equivalent={0}", directionString);
            Console.ReadKey();
        }
    }
}

 

C#编程(4_复杂的变量类型)

标签:style   blog   color   io   os   ar   sp   div   on   

原文地址:http://www.cnblogs.com/haizhibin1989/p/4051346.html


评论


亲,登录后才可以留言!