C# StringEnumerator Current
Description
StringEnumerator Current
gets the current element in
the collection.
Syntax
StringEnumerator.Current
has the following syntax.
public string Current { get; }
Example
using System;//from w w w. j a v a2 s. co m
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.