Export (0) Print
Expand All

ResourceReader.GetEnumerator Method

Returns an enumerator for this ResourceReader object.

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

abstract GetEnumerator : unit -> IDictionaryEnumerator  
override GetEnumerator : unit -> IDictionaryEnumerator

Return Value

Type: System.Collections.IDictionaryEnumerator
An enumerator for this ResourceReader object.




The reader has been closed or disposed, and cannot be accessed.

Typically, you enumerate resources by calling the GetEnumerator method and then repeatedly calling the MoveNext method on the returned IDictionaryEnumerator object until the method returns false. The resource name is available from the IDictionaryEnumerator.Key property; its value from the IDictionaryEnumerator.Value property. The example illustrates how to enumerate resources in this way.

The implementation of the IDictionaryEnumerator.Value property by the ResourceReader class can throw the following exceptions:

You can handle the exception by calling the GetResourceData method to retrieve information about the data type and the byte array assigned to the named resource. For more information, see the "Retrieving Resources by Name with GetResourceData" section in the ResourceReader class topic.

Important noteImportant

The ResourceReader class includes two methods that return enumerators. The GetEnumerator method returns an IDictionaryEnumerator interface object and is the recommended method to call when enumerating resources.

The example in this section uses the following .txt file named PatientForm.txt to define the resources used by an application.

Title="Top Pet Animal Clinic"
Label1="Patient Number:"
Label2="Pet Name:"
Label5="Date of Birth:"
Label9="Home Phone:"
Label10="Work Phone:"
Label11="Mobile Phone:"

You can compile the .txt file into a .resources file by issuing the following command:

resgen PatientForm.txt

The following example enumerates the resources in PatientForm.resources and displays the name and value of each.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft