ArrayList InsertRange() Method
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | class Program { static void Main(string[] args) { ArrayList colors = new ArrayList() { "Green", "SeaGreen", "SpringGreen", "LawnGreen" }; Console.WriteLine("ArrayList Elements...."); foreach (string color in colors) { Console.WriteLine(color); } List<string> redColors = new List<string>() { "Red", "DarkRed", "IndianRed" }; colors.InsertRange(2, redColors); Console.WriteLine(""); Console.WriteLine("After call InsertRange(index 2, ICollection) Method"); Console.WriteLine("Now ArrayList Elements..."); foreach (string color in colors) { Console.WriteLine(color); } Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ArrayList Elements.... Green SeaGreen SpringGreen LawnGreen After call InsertRange(index 2, ICollection) Method Now ArrayList Elements... Green SeaGreen Red DarkRed IndianRed SpringGreen LawnGreen |