Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ResourceManager::GetString Method (String)

Updated: May 2012

Returns the value of the specified String resource.

Namespace:  System.Resources
Assembly:  mscorlib (in mscorlib.dll)

virtual String^ GetString(
	String^ name


Type: System::String

The name of the resource to get.

Return Value

Type: System::String
The value of the resource localized for the caller's current culture settings. If a match is not possible, nullptr is returned.


The name parameter is nullptr.


The value of the specified resource is not a string.


No usable set of resources has been found, and there are no neutral culture resources.


The default culture's resources reside in a satellite assembly that could not be found.

The resource that is returned is localized for the culture determined by the cultural settings of the current Thread (this is accomplished using the current thread's CurrentUICulture property). If the resource has not been localized for that culture, the resource that is returned is localized for a best match (this is accomplished using the Parent property). Otherwise, nullptr is returned.

If no usable set of resources has been found, the ResourceManager falls back on the neutral culture's resources, which are expected to be in the main assembly. If an appropriate culture resource has not been found, a MissingManifestResourceException is thrown.

For more information about how resources are found, see "Resource Fallback Process" in Packaging and Deploying ResourcesPackaging and Deploying Resources.


The GetString method is thread-safe.

Caution noteCaution:

This method can throw more exceptions than are listed. One reason this might occur is if a method that this method calls throws an exception. For example, a FileLoadException might be thrown if an error was made deploying or installing a satellite assembly, or a SerializationException might be thrown if a user-defined type throws a user-defined exception when the type is deserialized.

The following code example gets a string resource using the current UI culture.

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 = gcnew ResourceManager( "items",Assembly::GetExecutingAssembly() );

   // Retrieve the value of the string resource named S"welcome".
   // The resource manager will retrieve the value of the 
   // localized resource using the caller's current culture setting.
   String^ str = rm->GetString( "welcome" );
   Console::WriteLine( str );

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0




May 2012

Added MissingSatelliteAssemblyException exception.

Content bug fix.

Community Additions

© 2016 Microsoft