在运行时以编程方式获取资源键的字符串表示形式

Get the string presentation of a resource key during runtime programatically

我有一个 .resx 文件。

我有这个 key "CustomerAreaIndexTitle" 和 value "Hello Customer".

此处不关心该值。

当我执行 Resource.CustomerAreaIndexTitle.ToString() 时,我得到了上面的值但是...我想要的是获取

资源键的字符串表示

"CustomerAreaIndexTitle"

这有可能吗?

使用:

nameof(Resource.CustomerAreaIndexTitle)

这是 C# 6 中的一项新功能,令人惊叹 用于此类事情。