Initializing an ArrayList
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class Program { static void Main(string[] args) { ArrayList colors = new ArrayList() { "Crimson", "IndianRed", "ForestGreen", "SeaGreen" }; Console.WriteLine("ArrayList Elements...."); foreach (string color in colors) { Console.WriteLine(color); } Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 | ArrayList Elements.... Crimson IndianRed ForestGreen SeaGreen |