Exemplo n.º 1
0
 // Uses the enumerator.
 // NOTE: The foreach statement is the preferred way of enumerating the contents of a collection.
 public static void PrintValues2(Int16Collection myCol)
 {
     System.Collections.IEnumerator myEnumerator = myCol.GetEnumerator();
     while (myEnumerator.MoveNext())
     {
         Console.WriteLine("   {0}", myEnumerator.Current);
     }
     Console.WriteLine();
 }
Exemplo n.º 2
0
        public static void PrintIndexAndValues(Int16Collection myCol)
        {
            int         i            = 0;
            IEnumerator myEnumerator = myCol.GetEnumerator();

            while (myEnumerator.MoveNext())
            {
                Console.WriteLine(" [{0}]: {1}", i++, myEnumerator.Current);
            }
            Console.WriteLine();
        }