ResourceSet Constructor (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.

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

public ResourceSet(
	string fileName
)

Parameters

fileName
Type: System.String

Resource file to read.

Exception Condition
ArgumentNullException

The fileName parameter is null.

The following code example defines a new instance of the ResourceSet class for a specific file, iterates through the resources used by that file, and displays their contents to the console.

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

    }
}

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: