introductory-examples/array-string-types/ex-array.cs - Demonstrations of array types in C#. | Lecture 2 - slide 10 : 43 Program 1 |
using System; class ArrayStringDemo{ public static void Main(){ string[] a1, a2 = {"a", "bb", "ccc"}; a1 = new string[]{"ccc", "bb", "a"}; int[,] b1 = new int[2,4], b2 = {{1,2,3,4}, {5,6,7,8}}; double[][] c1 = { new double[]{1.1, 2.2}, new double[]{3.3, 4.4, 5.5, 6.6} }; Console.WriteLine("Array lengths. a1:{0} b2:{1} c1:{2}", a1.Length, b2.Length, c1.Length); Array.Clear(a2,0,3); Array.Resize<string>(ref a2,10); Console.WriteLine("Lenght of a2: {0}", a2.Length); Console.WriteLine("Sorting a1:"); Array.Sort(a1); foreach(string str in a1) Console.WriteLine(str); } }