<p>I have an application on which I am implementing localization.</p>

<p>I now need to dynamically reference a name in the resouce file.</p>

<p>assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world"</p>

<p>normally, I will refer as: 
String result =Login.foo;
and result=="hello";</p>

<p>my problem is, that at code time, I do not know if I want to refer to foo, bar or baz - I have a string that contains either "foo", "bar" or "baz". </p>

<p>I need something like:</p>

<p>Login["foo"];</p>

<p>Does anyone know if there is any way to dynamically reference a string in a resource file?</p>

[{'answer_id': 29866, 'author': 'Konrad Rudolph', 'author_id': 1968, 'author_profile': 'https://Stackoverflow.com/users/1968', 'pm_score': 5, 'selected': True, 'text': '<p>You\'ll need to instance a <a href="http://msdn.microsoft.com/en-us/library/aa984408%28VS.71%29.aspx" rel="noreferrer"><code>ResourceManager</code></a> for the <code>Login.resx</code>:</p>\n\n<pre><code>var resman = new System.Resources.ResourceManager(\n    "RootNamespace.Login",\n    System.Reflection.Assembly.GetExecutingAssembly()\n)\nvar text = resman.GetString("resname");\n</code></pre>\n\n<p>It might help to look at the generated code in the code-behind files of the resource files that are created by the IDE. These files basically contain readonly properties for each resource that makes a query to an internal resource manager.</p>\n'}, {'answer_id': 2878059, 'author': 'StarCub', 'author_id': 109027, 'author_profile': 'https://Stackoverflow.com/users/109027', 'pm_score': 2, 'selected': False, 'text': '<p>If you put your Resource file in the App_GlobalResources folder like I did, you need to use</p>\n\n<blockquote>\n  <p>global::System.Resources.ResourceManager\n  temp = new\n  global::System.Resources.ResourceManager("RootNamespace.Login",\n  global::System.Reflection.Assembly.Load("App_GlobalResources"));</p>\n</blockquote>\n\n<p>It took me a while to figure this out. Hope this will help someone. :)</p>\n'}]
['https://Stackoverflow.com/questions/29845', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1090/']