The following example creates a Generic list of IPL teams and sorts them
The following code does it:
ListlstIPLTeams = new List (); lstIPLTeams.Add("Mumbai Indians"); lstIPLTeams.Add("Chennai SuperKings"); lstIPLTeams.Add("Kolkatta KnightRiders"); lstIPLTeams.Add("Deccan Chargers"); lstIPLTeams.Add("Rajastan Royals"); lstIPLTeams.Add("Delhi DareDevils"); lstIPLTeams.Add("KingsXI Punjab"); lstIPLTeams.Add("RC Bangalore"); Console.WriteLine("List Before Sorting"); Console.WriteLine("======================="); foreach (string IPL in lstIPLTeams) { Console.WriteLine(IPL.ToString()); } //Sort the Items lstIPLTeams.Sort(); Console.WriteLine("\nList After Sorting"); Console.WriteLine("======================="); foreach (string IPL in lstIPLTeams) { Console.WriteLine(IPL.ToString()); }
Here is the output
No comments:
Post a Comment