Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a string dynamically from strings resources

Tags:

c#

resources

I am working on a localised C#.NET application and we are using a strings.resx file to translate hardcoded strings in the application. I use the following code to extract them:

using MyNamespace.Resources  ...  string someString = strings.someString; 

But, now I want to be able to define the name of the string in the call, something like this:

string someString = GetString("someString"); 

I have been toying a little with the ResourceManager, but i can't find a way to direct it to my strings.resx file.

How do I do that?

like image 937
Bart Friederichs Avatar asked Nov 02 '12 11:11

Bart Friederichs


1 Answers

A little searching did the trick. I have the right ResourceManager available in my strings class:

ResourceManager rm = strings.ResourceManager; string someString = rm.GetString("someString"); 
like image 150
Bart Friederichs Avatar answered Oct 07 '22 09:10

Bart Friederichs