你需要打电话吗
.ToArray
?我不清楚为什么你不能循环添加到字典(或调用
.ToDictionary
)不过,你有介绍过吗?如果有
是
这里有个瓶颈,你可以试着回到
XmlReader
把它当作消防水管:
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element
&& reader.GetAttribute("attribName") == attribValue)
{
/* do something interesting for fun and profit */
}
}
不过,有了您现有的代码,我很想做到:
vm.Where(a => (string)a.Attribute(attribute) == ab)
区别在于不打电话
.Value
即使没有设置属性,它也应该工作。当然如果你
需要
如果始终设置此属性,则在这种情况下可以接受异常。