January 30, 2016
How to Sort An Array in C#/CSharp
For sorting an array in C#/CSharp, we make use of static method called sort which resides in Array class. Example is given below.
using System; namespace Hello_World { class Program { static void Main(string[] args) { int[] array = { 9, 8, 7, 4, 3 }; Console.WriteLine("Before Sorting"); foreach (int i in array) { Console.WriteLine(i); } Console.WriteLine("---------------------------"); Array.Sort(array); Console.WriteLine("After Sorting"); foreach (int i in array) { Console.WriteLine(i); } } } }