c#创建数组的几种写法
电脑版发表于:2020/9/6 22:35
                    代码如下:
    class Program
    {
        static void Main2(string[] args)
        {
            //写法1
            string[] str2 = new string[3];
            str2[0] = "hello2";
            //写法2
            string[] str = new string[3] { "hello", "word", "sdfs" };
            //方法3
            string[] str4 = new string[] { "hello4", "word", "sdfs" };
            //方法4
            string[] str5 = new[] { "hello5", "word", "sdfs", "sdfs5" };
            //方法5
            string[] str3 = { "hello3" };   
            Console.WriteLine(str[0]);
            Console.WriteLine(str2[0]);
            Console.WriteLine(str3[0]);
            Console.WriteLine(str4[0]);
            Console.WriteLine(str5[0]);
            Console.ReadLine();
        }
    }