public static void CollectionDemo() { Int16Collection myI16 = new Int16Collection { 1, 2, 3, 5, 7 }; Console.WriteLine("Contents of the collection (using foreach):"); PrintValues1(myI16); Console.WriteLine("Contents of the collection (using enumerator):"); PrintValues2(myI16); Console.WriteLine("Initial contents of the collection (using Count and Item):"); PrintIndexAndValues(myI16); Console.WriteLine("Contains 3: {0}", myI16.Contains(3)); Console.WriteLine("2 is at index {0}.", myI16.IndexOf(2)); Console.WriteLine(); myI16.Insert(3, 13); Console.WriteLine("Contents of the collection after inserting at index 3:"); PrintIndexAndValues(myI16); myI16[4] = 123; Console.WriteLine("Contents of the collection after setting the element at index 4 to 123:"); PrintIndexAndValues(myI16); myI16.Remove(2); Console.WriteLine("Contents of the collection after removing the element 2:"); PrintIndexAndValues(myI16); }