动态调用一个方法,只给定带有方法名称的字符串 c# 资源文件

Dynamically Invoke A Method, Given only Strings with Method Name c# Resources file

我有我的文件资源,我是这样打电话的:

string valueOfResource = namespaceName.Resources.nameOfString;

现在我做到了

string nameOfString = "Name_Res";
string buildstring = "namespaceName.Resources." + nameOfString;

我需要将 buildstring 的值转换为另一个字符串:

我想得到:

string valueOfResource = namespaceName.Resources.Name_Res;

我有:

string valueOfResource = buildstring;

有什么想法吗?

也许这会有所帮助

ResourceManager Class

The ResourceManager class retrieves resources from a binary .resources file that is embedded in an assembly or from a standalone .resources file

var myManager = new ResourceManager(typeof(MyResource));
var myString = myManager.GetString("StringKey");