C# StringEnumerator MoveNext
Description
StringEnumerator MoveNext
advances the enumerator
to the next element of the collection.
Syntax
StringEnumerator.MoveNext
has the following syntax.
public bool MoveNext()
Returns
StringEnumerator.MoveNext
method returns true if the enumerator was successfully advanced to the next element; false
if the enumerator has passed the end of the collection.
Example
using System;//from w w w . java2 s .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.