ResourceSet.GetEnumerator メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As ResourceSet Dim returnValue As IDictionaryEnumerator returnValue = instance.GetEnumerator
[ComVisibleAttribute(false)] public virtual IDictionaryEnumerator GetEnumerator ()
[ComVisibleAttribute(false)] public: virtual IDictionaryEnumerator^ GetEnumerator ()
/** @attribute ComVisibleAttribute(false) */ public IDictionaryEnumerator GetEnumerator ()
ComVisibleAttribute(false) public function GetEnumerator () : IDictionaryEnumerator
この ResourceSet の IDictionaryEnumerator。


列挙子は、コレクション内のデータの読み取りだけを許可します。列挙子を使用して基になるコレクションを変更することはできません。
初期状態では、列挙子はコレクションの最初の要素の前に位置しています。Reset を実行した場合も、列挙子はこの位置に戻されます。この位置で Current を呼び出すと、例外がスローされます。したがって、Current の値を読み取る前に、MoveNext を呼び出して、コレクションの最初の要素に列挙子を進める必要があります。
Current は、MoveNext または Reset が呼び出されるまでは同じオブジェクトを返します。MoveNext は、Current を次の要素に設定します。
コレクションの末尾を過ぎると、列挙子はコレクションの最後の要素の後ろに配置され、MoveNext を呼び出すと false が返されます。MoveNext への最後の呼び出しで false が返された場合に、Current を呼び出すと例外がスローされます。Current をコレクションの最初の要素に再び設定するには、Reset を呼び出してから、MoveNext を呼び出します。
列挙子は、コレクションが変更されない限り有効です。要素の追加、変更、削除などの変更がコレクションに対して実行されると、列挙子は回復不可能な無効状態になり、次に MoveNext または Reset を呼び出すと、InvalidOperationException がスローされます。コレクションが MoveNext と Current の間で変更された場合、列挙子が既に無効になっていても、Current は設定した要素を返します。
IDictionaryEnumerator.Entry プロパティを使用して、現在の要素に格納された値にアクセスできます。IDictionaryEnumerator.Key プロパティを使用して、現在の要素のキーにアクセスします。IDictionaryEnumerator.Value プロパティを使用して、現在の要素の値にアクセスします。
列挙子はコレクションへの排他アクセス権を持たないため、コレクションの列挙処理は、本質的にはスレッド セーフな処理ではありません。コレクションが同期されている場合でも、他のスレッドがそのコレクションを変更する可能性はあり、そのような状況が発生すると列挙子は例外をスローします。列挙処理を確実にスレッド セーフに行うには、列挙中にコレクションをロックするか、他のスレッドによって行われた変更によってスローされる例外をキャッチします。

ファイル items.resources の ResourceSetrs を作成する方法を次の例に示します。次に、GetEnumerator メソッドを使用して rs の IDictionaryEnumerator を作成します。IDictionaryEnumerator は rs を反復処理して、コンソールに内容を表示します。
Imports System Imports System.Resources Imports System.Collections Imports Microsoft.VisualBasic Class EnumerateResources Public Shared Sub Main() ' Create a ResourceSet for the file items.resources. Dim rs As New ResourceSet("items.resources") ' Create an IDictionaryEnumerator to read the data in the ResourceSet. Dim id As IDictionaryEnumerator = rs.GetEnumerator() ' Iterate through the ResourceSet and display the contents to the console. While id.MoveNext() Console.WriteLine(ControlChars.NewLine + "[{0}] " + ControlChars.Tab + "{1}", id.Key, id.Value) End While rs.Close() End Sub End Class
using System; using System.Resources; using System.Collections; class EnumerateResources { public static void Main() { // Create a ResourceSet for the file items.resources. ResourceSet rs = new ResourceSet("items.resources"); // Create an IDictionaryEnumerator to read the data in the ResourceSet. IDictionaryEnumerator id = rs.GetEnumerator(); // Iterate through the ResourceSet and display the contents to the console. while(id.MoveNext()) Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value); rs.Close(); } }
using namespace System; using namespace System::Resources; using namespace System::Collections; int main() { // Create a ResourceSet for the file items.resources. ResourceSet^ rs = gcnew ResourceSet( "items.resources" ); // Create an IDictionaryEnumerator* to read the data in the ResourceSet. IDictionaryEnumerator^ id = rs->GetEnumerator(); // Iterate through the ResourceSet and display the contents to the console. while ( id->MoveNext() ) Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value ); rs->Close(); }
import System.*; import System.Resources.*; import System.Collections.*; class EnumerateResources { public static void main(String[] args) { // Create a ResourceSet for the file items.resources. ResourceSet rs = new ResourceSet("items.resources"); // Create an IDictionaryEnumerator to read the data in the ResourceSet. IDictionaryEnumerator id = rs.GetEnumerator(); // Iterate through the ResourceSet and display the contents to // the console. while (id.MoveNext()) { Console.WriteLine("\n[{0}] \t{1}", id.get_Key(), id.get_Value()); } rs.Close(); } //main } //EnumerateResources

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


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

- ResourceSet.GetEnumerator メソッドのページへのリンク