using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{ 
    enum typeName:byte
    {

        east=2,
        //east,如果是east没有赋值则后面输出0 ,west输出1 默认的系统会给枚举赋值
        west,
        north,
        south
    }
    class Program
    {

        static void Main(string[] args)
        {
            typeName tn = typeName.east;
            Console.WriteLine(tn);//得到的结果为east
            
            Console.WriteLine((byte)tn);//得到的结果为2
            Console.WriteLine(typeName.west);//得到的结果为west
            Console.WriteLine((byte)typeName.west);//得到的结果为3 说明是在east的基础上加一
            //Console.WriteLine((byte)typeName.west)
            Console.ReadKey();
        }
    }
}


 关于枚举的作用 暂时还没有遇到过 这个只是一个学习过程中的一个例子 感觉新奇 写了下来 等到有用到了在msdn了

相关文章:

  • 2021-09-27
  • 2021-06-13
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2021-07-08
  • 2022-01-27
  • 2022-02-01
  • 2022-12-23
  • 2022-03-06
相关资源
相似解决方案