title: how do i calculate Qty To Be Issued in List collection
body: <pre><code>List&lt;Serials&gt; serials = new List&lt;Serials&gt;
  {
      new Serials { Id = 1, Qty = 30, SRNo = "SR-001" },
      new Serials { Id = 2, Qty = 70, SRNo = "SR-002" }
  };
  
  decimal? QtyToBeIssued = 50;
  
  // i tried however i did not get it in foreach loop
  foreach (var item in serials)
  {
      decimal? ToBeIssued = 0;
      if (QtyToBeIssued &gt; item.Qty)
      {
          ToBeIssued = item.Qty;
          item.Qty = item.Qty - ToBeIssued;
      }         
  }
  </code></pre>
  
  <p><code>QtyToBeIssued = 50</code> and serials collection's has first object has 30 i.e need to subtract <code>30 - 30 = 0</code>  and remaining <code>qty= 20</code>
  and that remaining 20 subtract from 2nd collection i.e 70-20 = 50 
  so my object collection will be looks like below after calculation 
  .i need to issue 30 from 1st record and 20 from second record.</p>
  
  <pre><code>Id = 1, Qty = 0, SRNo = "SR-001"
  Id = 2, Qty = 50, SRNo = "SR-002"
  </code></pre>