ResourceSet Constructors

Definition

Creates a new instance of the ResourceSet class.

Overloads

ResourceSet()

Initializes a new instance of the ResourceSet class with default properties.

ResourceSet(Stream)

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

ResourceSet(IResourceReader)

Creates a new instance of the ResourceSet class using the specified resource reader.

ResourceSet(String)

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

ResourceSet()

Source:
ResourceSet.cs
Source:
ResourceSet.cs
Source:
ResourceSet.cs

Initializes a new instance of the ResourceSet class with default properties.

C#
protected ResourceSet();

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ResourceSet(Stream)

Source:
ResourceSet.cs
Source:
ResourceSet.cs
Source:
ResourceSet.cs

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

C#
public ResourceSet(System.IO.Stream stream);
C#
[System.Security.SecurityCritical]
public ResourceSet(System.IO.Stream stream);

Parameters

stream
Stream

The Stream of resources to be read. The stream should refer to an existing resources file.

Attributes

Exceptions

The stream is not readable.

The stream parameter is null.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ResourceSet(IResourceReader)

Source:
ResourceSet.cs
Source:
ResourceSet.cs
Source:
ResourceSet.cs

Creates a new instance of the ResourceSet class using the specified resource reader.

C#
public ResourceSet(System.Resources.IResourceReader reader);

Parameters

reader
IResourceReader

The reader that will be used.

Exceptions

The reader parameter is null.

Remarks

You can use this constructor to support custom resource formats using a user-provided IResourceReader.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ResourceSet(String)

Source:
ResourceSet.cs
Source:
ResourceSet.cs
Source:
ResourceSet.cs

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

C#
public ResourceSet(string fileName);

Parameters

fileName
String

Resource file to read.

Exceptions

The fileName parameter is null.

Examples

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.

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

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1