StringEnumerator supports a simple iteration over a StringCollection.
using System;
using System.Collections.Specialized;
public class SamplesStringEnumerator {
public static void Main() {
StringCollection myCol = new StringCollection();
String[] myArr = new String[] { "a", "o", "y"};
myCol.AddRange( myArr );
StringEnumerator myEnumerator = myCol.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.WriteLine( "{0}", myEnumerator.Current );
myEnumerator.Reset();
if ( myEnumerator.MoveNext() )
Console.WriteLine( "The first element is {0}.", myEnumerator.Current );
}
}
Related examples in the same category