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

Dim instance As StringEnumerator Dim returnValue As Boolean returnValue = instance.MoveNext
列挙子が次の要素に正常に進んだ場合は true。列挙子がコレクションの末尾を越えた場合は false。


列挙子を作成した後や Reset を呼び出した後は、列挙子はコレクションの最初の要素の前に位置しています。MoveNext を最初に呼び出すと、列挙子はコレクションの最初の要素に移動します。
MoveNext がコレクションの末尾を過ぎると、列挙子はコレクションの最後の要素の後ろに配置され、MoveNext は false を返します。列挙子がこの位置にある場合、以降、MoveNext を呼び出しても、Reset が呼び出されるまでは false が返されます。
コレクションが変更されない限り、列挙子は有効なままです。要素の追加、変更、削除などの変更がコレクションに対して実行されると、列挙子は回復不可能な無効状態になり、次に MoveNext または Reset を呼び出すと InvalidOperationException がスローされます。MoveNext と Current の間でコレクションを変更すると、列挙子が無効になっている場合でも、Current が設定先の要素を返します。

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.MoveNext メソッドを検索する場合は、下記のリンクをクリックしてください。

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