Every now and then I come across a bunch of string literals littered through out some code and begin the task of moving them out into their own resource file (.resx).
Gaining access to these strings from C# is pretty easy however I’m yet to find anywhere explaining it the way I find simplest.
Assuming your resx file is stored in the App_GlobalResources folder, you can basically assign your resource file to a variable in your C# using the following syntax:
using Res = Resources.MyResourceFile |
This then gives you the ability to referene the contents of the resource file as properties in your code.
string x = Res.OneOfMyStringNames; |