Export (0) Print
Expand All

ResourceSet Constructor

.NET Framework 1.1

Creates a new instance of the ResourceSet class.

Overload List

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

Supported by the .NET Compact Framework.

[Visual Basic] Protected Sub New()
[C#] protected ResourceSet();
[C++] protected: ResourceSet();
[JScript] protected function ResourceSet();

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

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(IResourceReader)
[C#] public ResourceSet(IResourceReader);
[C++] public: ResourceSet(IResourceReader*);
[JScript] public function ResourceSet(IResourceReader);

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

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Stream)
[C#] public ResourceSet(Stream);
[C++] public: ResourceSet(Stream*);
[JScript] public function ResourceSet(Stream);

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

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(String)
[C#] public ResourceSet(string);
[C++] public: ResourceSet(String*);
[JScript] public function ResourceSet(String);

Example

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the ResourceSet constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System
Imports System.Resources
Imports System.Collections
Imports Microsoft.VisualBasic

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

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

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Resources;
using namespace System::Collections;

int main() {
    // Create a ResourceSet for the file items.resources.
    ResourceSet* rs = new ResourceSet(S"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(S"\n [{0}] \t {1}", id->Key, id->Value);

    rs->Close();

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

ResourceSet Class | ResourceSet Members | System.Resources Namespace

Show:
© 2014 Microsoft