IEnumerator.Current : IEnumerator « System.Collections « C# / C Sharp by API






IEnumerator.Current

  

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);
    }
    myEnumerator.Reset();
    myEnumerator.MoveNext();
    Console.WriteLine("myEnumerator.Current = " + myEnumerator.Current);
    
  }
}

   
    
  








Related examples in the same category

1.Implement IEnumerator
2.IEnumerator.MoveNext()
3.IEnumerator.Reset()