Get an enumerator from a range of elements in the ArrayList in CSharp

Description

The following code shows how to get an enumerator from a range of elements in the ArrayList.

Example


using System;//  www  .  ja  va  2s  . co  m
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");


        Console.WriteLine();

        IEnumerator e2 = colors.GetEnumerator(2, 4);
        while (e2.MoveNext())
        {
            Object obj = e2.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