Second class "array collection"

        the Main void static (String [] args)
        {
            Console.WriteLine ( "essentially one-dimensional array ================ used ================. 1");
            int [] = intArray new new int [. 3]; // definition array in length. 3
            intArray [. 1] = 123; // pass array, array, starting from 0
            Console.WriteLine ( "intArray [1]: " + intArray [1]); // worth retrieval method
            Console.WriteLine ( " ===== using the one-dimensional array of substantially ===== 2 ");
            int [] = intArray1 new new int [] {123, 12 is,. 11}; // direct assignment, without defining the length
            Console.WriteLine (" ===== using the one-dimensional array of substantially =====. 3 ");
            int [] = {intArray2. 1, 2,. 3,. 4,. 5,. 6};
            // to be acquired by traversing the output value
            for (int I = 0; I <intArray2.Length; I = I + 2)
            {
                Console. WriteLine(intArray2[i]);
            }

            Console.WriteLine ( "===== ===== using substantially two-dimensional array");
            int [,] of arr1 new new int [2,. 3] =; // define a two-dimensional array
            int [,] arr2 = int new new [2,. 3] {{123,. 11, 22 is}, {123,. 11, 12 is}};
            int [,] ARR3 = {
                {} 123,11,22, coordinates 0 //, / 0,1 / 0,2
                {44,33,55} // coordinates / 1,0 / 1,1 / 1,2
            };
            // second dimension of the second output element
            Console.WriteLine (arr3 [1, 1] ) ;
            for (int I = 0; I <2; I ++)
            {
                for (int J = 0; J <. 3; J ++)
                {
                    Console.Write (ARR3 [I, J] + "\ T");
                }
                Console.WriteLine ();
            }
            Console.WriteLine ( "irregular array of substantially ======= ====== use");
            int[][] arrs1 = {
                new int[] { 1,2},
                new int[] { 1,2,3,4,5},
                new int[] { 1,2,3,4,5,6,7,8,9}
            };
            Console.WriteLine(arrs1[2][4]);
            for (int i = 0; i < arrs1.Length; i++)
            {
                for (int J = 0; J <arrs1 [I] .Length; J ++)
                {
                    Console.Write (arrs1 [I] [J] + "\ T");
                }
                Console.WriteLine ();
            }
            Console.WriteLine ( " ====== ======= use substantially dynamic array ");
            ArrayList list = new ArrayList();
            list.Add(12);
            list.Add("AAC");
            list.Add(true);
            list.Add(2D);
            list.Add(2F);
            list.Add(DateTime.Now);
            list.Add(2.13);
            var aa = list[0];
            int bb = Convert.ToInt32(aa) + 1;
            foreach (var item in list)
            {
                Console.WriteLine(item);
            }

Guess you like

Origin www.cnblogs.com/zhangyuG/p/11140768.html