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
Post a Comment