北京网站设计排名,小辣椒网站开发,哪个建站系统好,如何用python做网站脚本语言版权声明#xff1a;本文为博主原创文章#xff0c;转载请在显著位置标明本文出处以及作者网名#xff0c;未经作者允许不得用于商业目的
版权声明#xff1a;本文为博主原创文章#xff0c;转载请在显著位置标明本文出处以及作者网名#xff0c;未经作者允许不得用于商…版权声明本文为博主原创文章转载请在显著位置标明本文出处以及作者网名未经作者允许不得用于商业目的
版权声明本文为博主原创文章转载请在显著位置标明本文出处以及作者网名未经作者允许不得用于商业目的
C#中数组和集合初始化以及赋值的常见代码如下 // 数组 //1 int[] a1 { 1, 2, 3, 4, 5 }; //2 int[] a2 new int[5] { 1, 2, 3, 4, 5 }; //3 二维数组 int[,] a3 { { 1, 2 }, { 3, 4 }, { 5, 6 } }; //4 二维数组 int[,] a4 new int[3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } }; //5 二维数组 var a5 new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } }; //6 数组的数组每个子数组可以有不同的长度 var a6 new int[][] { new int[] { 1, 2 }, new int[] { 3, 4 }, new int[] { 5, 6 } }; for (int i 0 ;i a6.Length ;i) { for(int j 0 ;j a6[i].Length ;j) Console.Write(a6[i][j] ); Console.WriteLine(); } // ArrayList //1 ArrayList alst1 new ArrayList(); alst1.Add(12); alst1.Add(34); alst1.Add(56); //2 string[] alstsample { 12, 34, 56 }; ArrayList alst2 new ArrayList(alstsample); //3 object[] alstsample1 { 12, ab, 34 }; ArrayList alst3 new ArrayList(alstsample1); //4 ArrayList alst4 new ArrayList(); alst4.AddRange(new string[] { 12, 34, 56 }); //5 ArrayList alst5 new ArrayList(new string[] { 12, 34, 56 }); //6 ArrayList alst6 new ArrayList(new object[] { ab, 12, 34 }); //7 ArrayList alst7 new ArrayList(){12, ab, 34}; // List //1 Liststring lst1 new Liststring(); lst1.Add(12); lst1.Add(34); lst1.Add(56); //2 string[] lstsample { 12, 34, 56 }; Liststring lst2 new Liststring(lstsample); //3 Liststring lst3 new Liststring(new string[] { 12, 34, 56 }); //4 Liststring lst4 new Liststring(); lst4.AddRange(new string[] { 12, 34, 56 }); //5 Liststring lst5 new Liststring { 12, 34, 56 }; 学习更多vb.net知识请参看vb.net 教程 目录
学习更多C#知识请参看C#教程 目录