I really don't know/have the answer, knowledge to find a resource value using a key from a resx
file in a assembly using c#.(or may be i am ignorant).
What would be the fastest code, way i can retrieve string values
or values
using a key from a resource file which is embedded as resource in a assembly. I am storing friendly messages for exceptions in the resource file and would like to use them when required.
Does a static class exist for this purpose?
Are there open source mature projects i can use for this?
If the resource is in the same assembly as the code, then the following will do:
String resourceValue = MyAssemblyNameSpace.Properties.Resources.ResourceName
Taken from this SO answer.
Assembly assembly = this.GetType().Assembly; ResourceManager resourceManager = new ResourceManager("Resources.Strings", assembly); string myString = resourceManager.GetString("value");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With