title: Getting Sum by looping a list within a list c#
body: <pre><code>public class GRNMaster
  {
      public string ID { get; set; }
      public string GRNNo { get; set; }
      public List&lt;GRNDetails&gt; GRNDetails { get; set; }
  }
  
  public class GRNDetails
  {
      public string GRNID { get; set; }
      public string ItemID { get; set; }
      public string ItemType { get; set; }
      public int RecevedQty { get; set; }
  }
  </code></pre>
  
  <p>above classes contains some of the properties of GRN header class and Detail class. i Grn can consist of many items so that "List GRNDetails" is there to keep them.</p>
  
  <p>I take a GRN List from a method which will store in the variable GrnList</p>
  
  <pre><code>public List&lt;GRNMaster&gt; GrnList
  </code></pre>
  
  <p>I have a list of Items IDs</p>
  
  <pre><code>public List&lt;string&gt; ItemIDList
  </code></pre>
  
  <p>In the controller I want to loop the ItemIDList (List ItemIDList) and get sum for that particular item based on the List</p>
  
  <pre><code>int ItemQty = 0;
  
  foreach (var item in ItemIDList)
  {
     ItemQty = 0;
  
     var ItemQty =  //some code using GrnList
  
      // rest of the programming code based on the 
      //  item qty
  }
  </code></pre>