c#枚举与数组初始化及使用小记

//客户端
    class Program
    {
       
        static void Main(string[] args)
        {
          //学习格式字符串的用法
            string[] str = new string[] { "a", "b" };
            string[] str1 = new string[2] { "c","d"};
            string[] str2 ={ "e","g"};

            //调用testenum枚举
            
            //要使用枚举,须先定义一个枚举类型的变量
            testenum enum1;
            enum1 = testenum.first;//为枚举类型的变量进行初始化值,是通过枚举类型的元素进提供
            Console.WriteLine("枚举类型testenum变量的值是:{0}", enum1);

            //if (enum1==testenum.first) //一般使用枚举类型变量==枚举类型.枚举类型的元素
            if ((int)enum1==1) //枚举变量显式转化为枚举元素对应的值
            {
                Console.WriteLine("haha");
            }
            Console.ReadKey();
        }

        //定义枚举类型
        public enum testenum:int //枚举默认类型是int
        {
            first=1,
            second=2,
            third=3
        }
        
    }
请使用浏览器的分享功能分享到微信等