title: How to Create Dictionary<int, string> via LINQ to XML?
body: <p>I have the following XML:</p>
  
  <pre><code>&lt;FootNotes&gt;
    &lt;Line id="10306" reference="*"&gt;&lt;/Line&gt;
    &lt;Line id="10308" reference="**"&gt;&lt;/Line&gt;
    &lt;Line id="10309" reference="***"&gt;&lt;/Line&gt;
    &lt;Line id="10310" reference="****"&gt;&lt;/Line&gt;
    &lt;Line id="10311" reference="+"&gt;&lt;/Line&gt;
  &lt;/FootNotes&gt;
  </code></pre>
  
  <p>and I have the following code where I'm to get a <code>Dictionary&lt;int, string&gt;()</code> object into</p>
  
  <pre><code>myObject.FootNotes 
  </code></pre>
  
  <p>so that each Line is a Key/Value pair</p>
  
  <pre><code>var doc = XElement.Parse(xmlString);
  
  var myObject = new
    {
        FootNotes = (from fn in doc
                         .Elements("FootNotes")
                         .Elements("Line")
                         .ToDictionary
                         (
                         column =&gt; (int) column.Attribute("id"),
                         column =&gt; (string) column.Attribute("reference")
                         )
                    )
    };
  </code></pre>
  
  <p>I am unsure how to get this from the XML into the object though. Can anyone suggest a solution?</p>