I have created some resource files to hold strings. I am displaying a MessageBox
by pointing it directly at a resource file named TestLocalResource
and a resource string named ThisIsMyTest
by simply referencing the resource string like this:
TestLocalResource.ThisIsMyTest
Now this does appear to work. But this leaves me wondering that by referencing the resource string this way, will I always be accessing the default resource file (e.g., TestLocalResource.resx
) rather than its German version (e.g., TestLocalResource.de-DE.resx
)?
So instead, do I have to use ResourceManager
? If so, how does ResourceManager
know the current language (culture)? Will I need to explicitly set it?
This is how I think I would need to use ResourceManager
:
ResourceManager resmgr =
new ResourceManager("MyApplication.MyResource", Assembly.GetExecutingAssembly());
But I'm hoping that there is a way to access localized resource strings in a more convenient fashion.
Messages.Designer.cs
(which is created by Visual Studio along withMessages.resx
) and noted that it incorporates calls toResourceManager
. So,ResourceManager
is indeed involved but the programmer does not need to access an instance of that class explicitly. – Ciliata