C# - Fastest way to get resource string from assembly

Deeptechtons picture Deeptechtons · Jan 24, 2012 · Viewed 72.3k times · Source

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?

Answer

herzbube picture herzbube · May 29, 2013

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.