Share via


ResourceManager.GetString メソッド

現在のカルチャ用に指定されている String リソースの値を取得します。

オーバーロードの一覧

指定した String リソースの値を返します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Overridable Function GetString(String) As String

[C#] public virtual string GetString(string);

[C++] public: virtual String* GetString(String*);

[JScript] public function GetString(String) : String;

指定されたカルチャ用にローカライズされている String リソースの値を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Overridable Function GetString(String, CultureInfo) As String

[C#] public virtual string GetString(string, CultureInfo);

[C++] public: virtual String* GetString(String*, CultureInfo*);

[JScript] public function GetString(String, CultureInfo) : String;

使用例

[Visual Basic, C#, C++] メモ   ここでは、GetString のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

ResourceManager クラス | ResourceManager メンバ | System.Resources 名前空間