/* Array class- It is a predefined class of base class libraries present * under the System namespace that provides a set of members using which * we can perform operations like Sorting, Reversing,Copying etc*/ //Example of Array class using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SD_array2 { class sd_array2 { static void Main(string[] args) { //assining a value at the time of declaration int[] arr = { 19, 23, 71, 93, 58, 37, 62, 87, 5, 49, 16, 8, 35, 2 }; for (int i = 0; i < arr.Length; i++) Console.Write(arr[i] + " "); Console.WriteLine(); { Array.Sort(arr); foreach (int i in arr) ; Console.Write(i + " "); Console.WriteLine(); Array.Reverse(arr); foreach (int i in arr) Console.Write(i+ " "); Console.WriteLine(); int[] brr = new int[10]; Array.Copy(arr, brr, 5); Console.Write(i + " "); Console.WriteLine(); } Console.ReadKey(); } } }
Friday, 8 February 2013
Example using Array Class
Labels:
C# basics
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment