枚举和结构

namespace EnumAndStructDemo
{

//定义枚举
    enum orientaton : byte(枚举中值的类型)
    {
        north=5,
        south=4,
        ease,
        west
    }

//定义结构
    struct route
    {
       public orientaton oo;
       public double d;
    }
    class Program
    {
        static void Main(string[] args)
        {
            byte a = 4;
            int b;
           
            orientaton o = (orientaton)a;
            route r;
            r.d = 12.2;
            r.oo = orientaton.west;
            Console.WriteLine("You select orientaton is {0}",o);
            Console.WriteLine("You select orientaton value is {0}", Convert.ToByte(o));
            Console.WriteLine("You select route's orientation  is {0} and distiace is {1}",r.oo,r.d);
            Console.ReadKey();
        }
     
    }
}

你可能感兴趣的:(枚举)