【发布时间】:2009-10-20 16:47:51
【问题描述】:
如何将以下节点存储到字典中,其中 int 是使用 LINQ 自动生成的键和字符串(节点的值)?
Elements:
XElement instructors =
XElement.Parse(
@"<instructors>
<instructor>Daniel</instructor>
<instructor>Joel</instructor>
<instructor>Eric</instructor>
<instructor>Scott</instructor>
<instructor>Joehan</instructor>
</instructors>"
);
partially attempted code is given below :
var qry = from instr in instructors.Elements("instructor")
where((p,index)=> **incomplete**).select..**incomplete**;
如何将我的选择变成Dictionary<int,String>? (键应从 1 开始;在 Linq 中,索引从零开始)。
【问题讨论】:
标签: c# linq-to-xml