title: Finding Sum in LINQ
body: <p>From the XML Document</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
   &lt;Data&gt;
     &lt;Products&gt;
        &lt;Product ProductId="1001" ProductName="ProductA" ProductPrice="123.45" /&gt; 
        &lt;Product ProductId="1002" ProductName="ProductB" ProductPrice="100.45" /&gt; 
    &lt;/Products&gt;
    ....
  </code></pre>
  
  <p>How to use "Sum" to find the sum of <code>ProductPrice?</code></p>
  
  <p>When i use</p>
  
  <pre><code>XDocument doc = XDocument.Load("Product.xml");
  
  var sum =
            from tot in (int)doc.Descendants("Product").
                         Attributes("ProductPrice").Sum()
                         select tot;
  </code></pre>
  
  <p>I receive Error : <strong>"can not convert type system.xml.linq.xmlattribute to int"</strong>.</p>