ResourceManager.GetString Method
Gets the value of the specified String resource for the current culture.
Overload List
Returns the value of the specified String resource.
Supported by the .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;
Gets the value of the String resource localized for the specified culture.
Supported by the .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;
Example
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of GetString. 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
in the upper-left corner of the page.
See Also
ResourceManager Class | ResourceManager Members | System.Resources Namespace