Export (0) Print
Expand All

ResourceManager Constructor

.NET Framework 1.1

Initializes a new instance of the ResourceManager class.

Overload List

Initializes a new instance of the ResourceManager class with default values.

Supported by the .NET Compact Framework.

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

Creates a ResourceManager that looks up resources in satellite assemblies based on information from the specified Type.

Supported by the .NET Compact Framework.

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

Initializes a new instance of the ResourceManager class that looks up resources contained in files derived from the specified root name using the given Assembly.

Supported by the .NET Compact Framework.

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

Initializes a new instance of the ResourceManager class that looks up resources contained in files derived from the specified root name using the given Assembly.

Supported by the .NET Compact Framework.

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

Example

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

Class ResourcesExample
   
    Public Shared Sub Main()
        ' Create a resource manager to retrieve resources.
        Dim rm As New ResourceManager("items", _
           [Assembly].GetExecutingAssembly())
       
        ' Get the culture of the currently executing thread.
        ' The value of ci will determine the culture of
        ' the resources that the resource manager retrieves.
        Dim ci As CultureInfo = Thread.CurrentThread.CurrentCulture
      
        ' Retrieve the value of the string resource named 
        ' "welcome" localized for the culture specified by ci.
        Dim str As [String] = rm.GetString("welcome", ci)
        Console.WriteLine(str)
    End Sub
End Class

[C#] 
using System;
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Reflection;

class ResourcesExample 
{
    public static void Main() 
    {
       // Create a resource manager to retrieve resources.
       ResourceManager rm = new ResourceManager("items", 
          Assembly.GetExecutingAssembly());

       // Get the culture of the currently executing thread.
       // The value of ci will determine the culture of
       // the resources that the resource manager retrieves.
       CultureInfo ci = Thread.CurrentThread.CurrentCulture;
        
       // Retrieve the value of the string resource named 
       // "welcome", localized for the culture specified by ci.
       String str = rm.GetString("welcome", ci);
       Console.WriteLine(str);
    }
}

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

using namespace System;
using namespace System::Globalization;
using namespace System::Threading;
using namespace System::Resources;
using namespace System::Reflection;

int main() {
    // Create a resource manager to retrieve resources.
    ResourceManager* rm = new ResourceManager(S"items",
        Assembly::GetExecutingAssembly());

    // Get the culture of the currently executing thread.
    // The value of ci will determine the culture of
    // the resources that the resource manager retrieves.
    CultureInfo*  ci = Thread::CurrentThread->CurrentCulture;

    // Retrieve the value of the string resource named
    // S"welcome", localized for the culture specified by ci.
    String*  str = rm->GetString(S"welcome", ci);
    Console::WriteLine(str);
}

[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

ResourceManager Class | ResourceManager Members | System.Resources Namespace

Show:
© 2014 Microsoft