c# - How to get Name by string Value from a .NET resource (RESX) file -


here's how resx file like:

name            value        comments rule_seconds    seconds      seconds rule_sound      sound        sound 

what want is: name string value, below:

public string getresxnamebyvalue(string value) { // code name value } 

and implement below:

string str = getresxnamebyvalue("seconds"); 

so str return rule_seconds

thanks!

this work

private string getresxnamebyvalue(string value)     {             system.resources.resourcemanager rm = new system.resources.resourcemanager("yournamespace.yourresxfilename", this.gettype().assembly);           var entry=             rm.getresourceset(system.threading.thread.currentthread.currentculture, true, true)               .oftype<dictionaryentry>()               .firstordefault(e => e.value.tostring() ==value);          var key = entry.key.tostring();         return key;      } 

with additional error checking..


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -