How to add data to a dictonary in c#

Posted by Pramodh on Stack Overflow See other posts from Stack Overflow or by Pramodh
Published on 2010-05-13T05:42:26Z Indexed on 2010/05/13 5:54 UTC
Read the original article Hit count: 181

Filed under:
|

Dear all,

How to add data to dictonary from xml fil

scenerio:

I've declared a dictonary like

 Dictonary<string,string> SampleDict=new Dictonary<string,string>();

and my xml file is like

 <Data>
   <Element ValOne="1" ValTwo="0" />
   <Element ValOne="2" ValTwo="2" />
   <Element ValOne="3" ValTwo="4" />
   <Element ValOne="4" ValTwo="6" />
   <Element ValOne="5" ValTwo="8" />
   <Element ValOne="6" ValTwo="10" />
   <Element ValOne="7" ValTwo="12" />
   <Element ValOne="8" ValTwo="14" />
   <Element ValOne="9" ValTwo="16" />
   <Element ValOne="10" ValTwo="18" />
</Data>

i need to read the value of "ValOne" and "ValTwo" using LINQ and insert the same into the above declared dictonary

Please help me to do this

Thanks in advance

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#