我从资源文件中存储了所有数据元素,如下所示:
XDocument xDocTranslated = XDocument.Load(TranslatedFile);
var resultTranslated = from item in xDocTranslated.Descendants("data")
select new
{
Name = (string)item.Attribute("name"),
Value = (string)item.Element("value")
};
我有一个字符串列表,我想与上面的结果进行比较,如果它们匹配,我想存储新值。
我正在尝试这样的事情:
//Get each string that i want to translate
foreach (var name in StringsToTranslatelist)
{
//Look up the translated value from data extracted from xml file
var value= from entry in resultTranslated
where entry.Name == name; <--this does not work
}
我应该在这里使用什么 LINQ 语句?如何搜索 resultTranslated ??