Linq to XML -Dictionary转换
如何将以下节点存储到Dictionary中,其中int是使用LINQ的自动生成的Key和字符串(节点的值)?
Elements:
XElement instructors = XElement.Parse( @" Daniel Joel Eric Scott Joehan " );
partially attempted code is given below :
var qry = from instr in instructors.Elements("instructor") where((p,index)=> **incomplete**).select..**incomplete**;
如何将我的选择转换为Dictionary
? (键应从1开始;在Linq标记从零开始)。
怎么样:
上述就是C#学习教程:Linq to XML -Dictionary转换分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
var dictionary = instructors.Elements("instructor") .Select((element, index) => new { element, index }) .ToDictionary(x => x.index + 1, x => x.element.Value);
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1006953.html