Get an enumerator using the GetEnumerator() method and use it to read the elements in ArrayList : ArrayList : Data Structure C# Examples


C# Examples » Data Structure » ArrayList »

 

Get an enumerator using the GetEnumerator() method and use it to read the elements in ArrayList









    
using  System;
using  System.Collections;

class  MainClass
{
    public  static  void  Main()
    {
        ArrayList  myArrayList  =  new  ArrayList();
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        myArrayList.Add("A");
        

        string[]  anotherStringArray  =  {"Here's",  "some",  "more",  "text"};
        myArrayList.SetRange(0,  anotherStringArray);

        Console.WriteLine("Using  the  GetEnumerator()  method  to  get  an  enumerator");
        IEnumerator  myEnumerator  =  myArrayList.GetEnumerator();
        while  (myEnumerator.MoveNext())
        {
            Console.WriteLine("myEnumerator.Current  =  "  +  myEnumerator.Current);
        }
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» ArrayList