The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
StringEnumerator::Reset Method ()
.NET Framework (current version)
Sets the enumerator to its initial position, which is before the first element in the collection.
Assembly: System (in System.dll)
| Exception | Condition |
|---|---|
| InvalidOperationException | The collection was modified after the enumerator was created. |
The following code example demonstrates several of the properties and methods of StringEnumerator.
#using <System.dll> using namespace System; using namespace System::Collections::Specialized; int main() { // Creates and initializes a StringCollection. StringCollection^ myCol = gcnew StringCollection; array<String^>^myArr = {"red","orange","yellow","green","blue","indigo","violet"}; myCol->AddRange( myArr ); // Enumerates the elements in the StringCollection. StringEnumerator^ myEnumerator = myCol->GetEnumerator(); while ( myEnumerator->MoveNext() ) Console::WriteLine( "{0}", myEnumerator->Current ); Console::WriteLine(); // Resets the enumerator and displays the first element again. myEnumerator->Reset(); if ( myEnumerator->MoveNext() ) Console::WriteLine( "The first element is {0}.", myEnumerator->Current ); } /* This code produces the following output. red orange yellow green blue indigo violet The first element is red. */
Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Available since 10
.NET Framework
Available since 1.1
Show: