c# - Linq to XML -Dictionary conversion -


How to store nodes in a dictionary where int is an autogenerated key and string (value of node ) Using LINQ?

element:

  XElement instructors = XElement.Parse (@ "& lt; Trainers & Gt; Instructor & gt; Daniel & lt; / instructor & gt; & lt; Trainer & gt; Joel & lt; / instructor & gt; Instructor & gt; Eric & lt; / instructor & gt; Instructor & Gt; Scott & lt; / instructor & gt; & lt; instructor & gt; Joehan & lt; / instructor & gt; & lt; / trainer & gt; ");  

Partial effort code is given below:

  var qry = in trainers From instr Element ("trainer") where ((p, index) => ** incomplete **) .. ** ** ** incomplete **;  

My selection to in dictionary & lt; Int, string & gt; How to turn on ? (The key should start with 1, Lin must start in the Indies with zero).

How about:

x.index + 1, x) = & Gt; X.element.Value);

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -