title: Get sum of the value from list using linq?
body: <p>I am trying to get the sum of the value from list of list using linq ?my data is as below code </p>
  
  <pre><code>        List&lt;List&lt;string&gt;&gt; allData = new List&lt;List&lt;string&gt;&gt;();
          using (StreamReader reader = new StreamReader(path))
          {
              while (!reader.EndOfStream)
              {
                  List&lt;string&gt; dataList;
                  dataList = reader.ReadLine().Split('|').ToList();
                  allData.Add(dataList);
              }
          }
  </code></pre>
  
  <p>which gives me data in <code>allData</code> as below </p>
  
  <pre><code>           allData--&gt;[0]--&gt;[0]-'name1'
                             [1]-'sub'
                             [2]-'12'
                       [1]--&gt;[0]-'name2'
                             [1]-'sub'
                             [2]-'15'  
                       [2]--&gt;[0]-'name1'
                             [1]-'sub2'
                             [2]-'15'
      //and so on ....
  </code></pre>
  
  <p>i have applied group by that gives me grouping by the name but i am not able to figure out how to get the sum of the marks for each name ?</p>
  
  <pre><code>      var grouped = allData.GroupBy(x =&gt; x[0]);
  </code></pre>
  
  <p>after this i get all matching name grouped into one but now how to get sum of the marks for that group ? any help would be great ?</p>
  
  <pre><code>  Output should be  name1=27 and name2=15 and so on.
  </code></pre>