Export (0) Print
Expand All

ResourceReader.GetEnumerator Method

Returns an enumerator for this ResourceReader.

Namespace: System.Resources
Assembly: mscorlib (in mscorlib.dll)

public IDictionaryEnumerator GetEnumerator ()
public final IDictionaryEnumerator GetEnumerator ()
public final function GetEnumerator () : IDictionaryEnumerator
Not applicable.

Return Value

An IDictionaryEnumerator for this ResourceReader.

Exception typeCondition

InvalidOperationException

The reader has already been closed, and thus cannot be accessed.

The following code example uses the GetEnumerator method to iterate through the resources of a specific file.

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();     
 
    }
}

import System.*;
import System.Resources.*;
import System.Collections.*;

class EnumerateResources
{   

    public static void main(String[] args)
    {
        // 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.get_Key(), id.get_Value());
        }
        rr.Close();
    } //main 
} //EnumerateResources

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft