Get an enumerator from in entire ArrayList in CSharp

Description

The following code shows how to get an enumerator from in entire ArrayList.

Example


/*  w w  w  . ja  v  a 2 s .c  om*/
using System;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        ArrayList colors = new ArrayList();
        colors.Add("A");
        colors.Add("B");
        colors.Add("C");
        colors.Add("D");
        colors.Add("E");
        colors.Add("F");
        colors.Add("G");
        colors.Add("H");
        colors.Add("I");

        IEnumerator e = colors.GetEnumerator();
        while (e.MoveNext())
        {
            Object obj = e.Current;
            Console.WriteLine(obj);
        }


    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary