Export (0) Print
Expand All

ResourceReader.GetEnumerator Method

Returns an enumerator for this ResourceReader.

[Visual Basic]
Public Overridable Function GetEnumerator() As IDictionaryEnumerator _
   Implements IResourceReader.GetEnumerator
[C#]
public virtual IDictionaryEnumerator GetEnumerator();
[C++]
public: virtual IDictionaryEnumerator* GetEnumerator();
[JScript]
public function GetEnumerator() : IDictionaryEnumerator;

Return Value

An IDictionaryEnumerator for this ResourceReader.

Implements

IResourceReader.GetEnumerator

Exceptions

Exception Type Condition
InvalidOperationException The reader has already been closed, and thus cannot be accessed.

Example

[Visual Basic] 
Imports System
Imports System.Resources
Imports System.Collections
Imports Microsoft.VisualBasic

Class EnumerateResources
   
   Public Shared Sub Main()
      ' Create a ResourceReader for the file items.resources.
      Dim rr As New ResourceReader("items.resources")      
      
      ' Create an IDictionaryEnumerator to iterate through the resources.
      Dim id As IDictionaryEnumerator = rr.GetEnumerator()
      
      ' Iterate through the resources and display the contents to the console. 
      While id.MoveNext()
         Console.WriteLine(ControlChars.NewLine + "[{0}] " + ControlChars.Tab + "{1}", id.Key, id.Value)
      End While 

      rr.Close()

   End Sub

End Class

[C#] 
using System;
using System.Resources;
using System.Collections;

class EnumerateResources 
{
    public static void Main() 
    {
        // Create a ResourceReader for the file items.resources.
        ResourceReader rr = new ResourceReader("items.resources"); 

        
        // Create an IDictionaryEnumerator to iterate through the resources.
        IDictionaryEnumerator id = rr.GetEnumerator(); 

        // Iterate through the resources and display the contents to the console. 
        while(id.MoveNext())
          Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value); 

        rr.Close();     
 
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Resources;
using namespace System::Collections;

int main() {
    // Create a ResourceReader for the file items.resources.
    ResourceReader* rr = new ResourceReader(S"items.resources");


    // Create an IDictionaryEnumerator* to iterate through the resources.
    IDictionaryEnumerator* id = rr->GetEnumerator();

    // Iterate through the resources and display the contents to the console.
    while(id->MoveNext())
        Console::WriteLine(S"\n [{0}] \t {1}", id->Key, id->Value);

    rr->Close();

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

ResourceReader Class | ResourceReader Members | System.Resources Namespace | IDictionary | IDictionaryEnumerator

Show:
© 2014 Microsoft