5月14日 枚举类型

namespace _5月14日_枚举类型
{
    class Program
    {
        enum meiju//不规定值类型的时候默认为int
        { 
            one=3,//不是赋值,是指向索引,3号索引是one的索引位置
            two=6,//6号索引是two这个常量
            three,//每行用逗号隔开,最后的逗号可以省略
            four = two//若一个常量等于之前的一个常量,那么就等于这个常量,这里是赋值
            
        }
        enum meiju1
        { 
            one=1,
            two=2,
            three,
            four=three,
        }



        static void Main(string[] args)
        {
            //结构体:定义下一组变量


            //枚举类型:定义下一组常量,只能引用,不能赋值  const int q=5;

            Console.WriteLine(meiju.one);//打印出来的是“one”
            Console.WriteLine(meiju.four);//打印出来的是“two”


            Console.WriteLine(meiju1.four);//打印出来的是“three”

            Console.ReadLine();
        }
    }
}
原文地址:https://www.cnblogs.com/juyangchao12/p/5494662.html