Let us take our own IPL example. The current IPL has eight teams that are part of the list
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");
From next year two new teams- Pune and Kochi - will be part of IPL
Hence we are adding those two teams to an Array and adding the array using AddRange method
string[] NewIPLTeams = { "Pune", "Kochi" }; lstIPLTeams.AddRange(NewIPLTeams); Console.WriteLine("\nList After Add Range"); Console.WriteLine("======================="); foreach (string IPL in lstIPLTeams) { Console.WriteLine(IPL.ToString()); }
This will add Pune and Kochi to end of the list
No comments:
Post a Comment