ResourceManager.GetString Method (String)


Returns the value of the specified string resource.

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

public virtual string GetString(
	string name


Type: System.String

The name of the resource to retrieve.

Return Value

Type: System.String

The value of the resource localized for the caller's current UI culture, or null if name cannot be found in a resource set.

Exception Condition

The name parameter is null.


The value of the specified resource is not a string.


No usable set of resources has been found, and there are no resources for the default culture. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.


The default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

The GetString(String) method is thread safe.

In desktop apps, the resource that is returned is localized for the UI culture of the current thread, as defined by the CultureInfo.CurrentUICulture property. If the resource has not been localized for that culture, the resource manager probes for a resource by following the steps outlined in the "Resource Fallback Process" section of the Packaging and Deploying Resources in Desktop Apps article. If no usable set of localized resources is found, the resource manager falls back on the default culture's resources. If the resource manager cannot load the default culture's resource set, the method throws a MissingManifestResourceException exception or, if the resource set is expected to reside in a satellite assembly, a MissingSatelliteAssemblyException exception. If the resource manager can load an appropriate resource set but cannot find a resource named name, the method returns null.

The IgnoreCase property determines whether the comparison of name with the names of resources is case-insensitive (the default) or case-sensitive.


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 exception might be thrown if an error was made deploying or installing a satellite assembly, or a SerializationException exception might be thrown if a user-defined type throws a user-defined exception when the type is deserialized.


Although the ResourceManager class is supported in Windows 8.x Store apps, we do not recommend its use. Use this class only when you develop Portable Class Library projects that can be used with Windows 8.x Store apps. To retrieve resources from Windows 8.x Store apps, use the Windows.ApplicationModel.Resources.ResourceLoader class instead.

In Windows 8.x Store apps, the GetString(String) method returns the value of the name string resource, localized for the caller's current UI culture settings. The list of cultures is derived from the operating system's preferred UI language list. If the resource manager cannot match name, the method returns null.

The following example uses the GetString method to retrieve culture-specific resources. It consists of resources compiled from .txt files for the English (en), French (France) (fr-FR), and Russian (Russia) (ru-RU) cultures. The example changes the current culture and current UI culture to English (United States), French (France), Russian (Russia), and Swedish (Sweden). It then calls the GetString method to retrieve the localized string, which it displays along with the current day and month. Notice that the output displays the appropriate localized string except when the current UI culture is Swedish (Sweden). Because Swedish language resources are unavailable, the app instead uses the resources of the default culture, which is English. The example requires the text-based resource files listed in following table. Each has a single string resource named DateStart.


File name

Resource name

Resource value




Today is



Aujourd'hui, c'est le




You can use the following batch file to compile the C# example. For Visual Basic, change csc to vbc, and change the extension of the source code file from .cs to .vb.

resgen DateStrings.txt
csc showdate.cs /resource:DateStrings.resources

md fr-FR
al /out:fr-FR\Showdate.resources.dll /culture:fr-FR / 

md ru-RU
al /out:ru-RU\Showdate.resources.dll /culture:ru-RU /

Here's the source code for the example (ShowDate.vb for the Visual Basic version or ShowDate.cs for the C# version).

using System;
using System.Globalization;
using System.Resources;
using System.Threading;


public class Example
   public static void Main()
      string[] cultureNames = { "en-US", "fr-FR", "ru-RU", "sv-SE" };
      ResourceManager rm = new ResourceManager("DateStrings",

      foreach (var cultureName in cultureNames) {
         CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName);
         Thread.CurrentThread.CurrentCulture = culture; 
         Thread.CurrentThread.CurrentUICulture = culture;

         Console.WriteLine("Current UI Culture: {0}", 
         string dateString = rm.GetString("DateStart");
         Console.WriteLine("{0} {1:M}.\n", dateString, DateTime.Now);                           
// The example displays output similar to the following:
//       Current UI Culture: en-US
//       Today is February 03.
//       Current UI Culture: fr-FR
//       Aujourd'hui, c'est le 3 février
//       Current UI Culture: ru-RU
//       Сегодня февраля 03.
//       Current UI Culture: sv-SE
//       Today is den 3 februari.

when invoked late-bound through mechanisms such as Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess.

Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft