c# - ResourceManager 和 ResourceSet 给我空或 null 结果

Thi*_*aud 6 c#

我目前正在处理资源文件来翻译一些文本。

我有主要的“RevitString.resx”和“RevitString.fr-FR.resx”。它们都具有相同的密钥和翻译值并且是公开的。

我想在我的 C# 代码中使用它们,代码如下:

ResourceSet resourceSet = Resources.Languages.Tables.RevitString.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
type = (from ResourceDictionary x 
        in resourceSet 
        where x.Keys.ToString() == _type.Definition.ParameterGroup.ToString()
        select x.Values.ToString()).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)

但是当我运行这个程序时,我得到了一个空的 ResourceSet,当我查看 ResourceManager 时,“ResourceSets”为空,计数 = 0。

我做错了什么 ?

我已经看过一些这样的帖子

谢谢你!

Thi*_*aud 2

感谢 GibralterTop 给了我很好的链接。

这是我所使用的知识

ResourceSet resourceSet = Resources.Languages.Tables.RevitString.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
IDictionaryEnumerator enumerator = resourceSet.GetEnumerator();
while (enumerator.MoveNext())
{
switch(enumerator.Key)...
Run Code Online (Sandbox Code Playgroud)