GetString Method (String, CultureInfo)
Collapse the table of content
Expand the table of content

ResourceManager.GetString Method (String, CultureInfo)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the value of the String resource localized for the specified culture.

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

public virtual string GetString(
	string name,
	CultureInfo culture


Type: System.String
The name of the resource to get.
Type: System.Globalization.CultureInfo
The culture for which the resource is localized. Note that if the resource is not localized for this culture, the lookup will fall back using the culture's Parent property, stopping after looking in the neutral culture.
If this value is null, the CultureInfo is obtained using the culture's CurrentUICulture property.

Return Value

Type: System.String
The value of the resource localized for the specified culture. If a best match is not possible, null is returned.


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 neutral culture resources.

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 culture's Parent property). Otherwise, null 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.


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.

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

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

class Example
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
      // Create a resource manager to retrieve resources.
      ResourceManager rm = new ResourceManager("items",

      // 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);
      outputBlock.Text += str + "\n";

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2016 Microsoft