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

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

protected:
 ResourceSet();
protected ResourceSet ();
Protected Sub New ()

Applies to

ResourceSet(Stream)

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

public:
 ResourceSet(System::IO::Stream ^ stream);
public ResourceSet (System.IO.Stream stream);
[System.Security.SecurityCritical]
public ResourceSet (System.IO.Stream stream);
new System.Resources.ResourceSet : System.IO.Stream -> System.Resources.ResourceSet
[<System.Security.SecurityCritical>]
new System.Resources.ResourceSet : System.IO.Stream -> System.Resources.ResourceSet
Public Sub New (stream As 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

ResourceSet(IResourceReader)

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

public:
 ResourceSet(System::Resources::IResourceReader ^ reader);
public ResourceSet (System.Resources.IResourceReader reader);
new System.Resources.ResourceSet : System.Resources.IResourceReader -> System.Resources.ResourceSet
Public Sub New (reader As IResourceReader)

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

ResourceSet(String)

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

public:
 ResourceSet(System::String ^ fileName);
public ResourceSet (string fileName);
new System.Resources.ResourceSet : string -> System.Resources.ResourceSet
Public Sub New (fileName As String)

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.

using namespace System;
using namespace System::Resources;
using namespace System::Collections;
int main()
{
   
   // Create a ResourceSet for the file items.resources.
   ResourceSet^ rs = gcnew 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();
}
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();
    }
}
Imports System.Resources
Imports System.Collections

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

      rs.Close()

   End Sub

End Class

Applies to