2 // Tests collection initialization
5 using System.Collections;
6 using System.Collections.Generic;
12 ArrayList numbers = new ArrayList ();
18 Next = new Wrap (100);
26 public ArrayList Numbers {
33 static void TestList (List<int> list, int expectedCount)
35 if (list.Count != expectedCount)
36 throw new ApplicationException (expectedCount.ToString ());
38 foreach (int i in list)
39 Console.WriteLine (i);
42 public static int Main ()
44 ArrayList collection = new ArrayList { "Foo", null, 1 };
45 if (collection.Count != 3)
48 if ((string)collection [0] != "Foo")
51 if ((int)collection [2] != 1)
54 List<string> generic_collection = new List<string> { "Hello", "World" };
55 foreach (string s in generic_collection)
60 a = new List<Wrap> () {
68 Numbers = { collection, }
80 if ((int)a [0].Numbers [1] != 10)
83 new List<int> { 1, 2, 3, 4 };
84 TestList (new List<int> { 1, 2, 3, 4 }, 4);
88 Console.WriteLine ("OK");