Search code examples
c#.netstring.net-4.0

Read string from .resx file in C#


How can I read a string from a .resx file in C#?


Solution

  • This example is from the MSDN page on ResourceManager.GetString():

    // Create a resource manager to retrieve resources.
    ResourceManager rm = new ResourceManager("items", Assembly.GetExecutingAssembly());
    
    // Retrieve the value of the string resource named "welcome".
    // The resource manager will retrieve the value of the  
    // localized resource using the caller's current culture setting.
    String str = rm.GetString("welcome");