C# StringEnumerator Reset

Description

StringEnumerator Reset sets the enumerator to its initial position, which is before the first element in the collection.

Syntax

StringEnumerator.Reset has the following syntax.


public void Reset()

Returns

StringEnumerator.Reset method returns

Example


using System;//from w w w .j  a  v  a 2s  . c  om
using System.Collections.Specialized;

public class SamplesStringEnumerator  {

   public static void Main()  {
      StringCollection myCol = new StringCollection();
      String[] myArr = new String[] { "A", "B", "C"};
      myCol.AddRange( myArr );

      StringEnumerator myEnumerator = myCol.GetEnumerator();
      while ( myEnumerator.MoveNext() )
         Console.WriteLine( "{0}", myEnumerator.Current );
      Console.WriteLine();

      myEnumerator.Reset();
      if ( myEnumerator.MoveNext() )
         Console.WriteLine( "The first element is {0}.", myEnumerator.Current );

   }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections.Specialized »




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator