StringEnumerator.Reset メソッド
アセンブリ: System (system.dll 内)



Reset は、列挙子をコレクションの先頭、つまり最初の要素の前に移動します。Reset を実行した後に、コレクションの最初の要素に列挙子を進めるには、Current の値を読み取る前に MoveNext を呼び出す必要があります。

StringEnumerator のプロパティとメソッドのいくつかの例を次に示します。
Imports System Imports System.Collections.Specialized Public Class SamplesStringEnumerator Public Shared Sub Main() ' Creates and initializes a StringCollection. Dim myCol As New StringCollection() Dim myArr() As [String] = {"red", "orange", "yellow", "green", "blue", "indigo", "violet"} myCol.AddRange(myArr) ' Enumerates the elements in the StringCollection. Dim myEnumerator As StringEnumerator = myCol.GetEnumerator() While myEnumerator.MoveNext() Console.WriteLine("{0}", myEnumerator.Current) End While Console.WriteLine() ' Resets the enumerator and displays the first element again. myEnumerator.Reset() If myEnumerator.MoveNext() Then Console.WriteLine("The first element is {0}.", myEnumerator.Current) End If End Sub 'Main End Class 'SamplesStringEnumerator 'This code produces the following output. ' 'red 'orange 'yellow 'green 'blue 'indigo 'violet ' 'The first element is red.
using System; using System.Collections.Specialized; public class SamplesStringEnumerator { public static void Main() { // Creates and initializes a StringCollection. StringCollection myCol = new StringCollection(); String[] myArr = new String[] { "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. */
#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. */
import System.* ; import System.Collections.Specialized.* ; public class SamplesStringEnumerator { public static void main(String[] args) { // Creates and initializes a StringCollection. StringCollection myCol = new StringCollection(); String myArr[] = new String[]{"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.get_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.get_Current()); } } //main } //SamplesStringEnumerator /* This code produces the following output. red orange yellow green blue indigo violet The first element is red. */

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からStringEnumerator.Reset メソッドを検索する場合は、下記のリンクをクリックしてください。

- StringEnumerator.Reset メソッドのページへのリンク