title: Foreach loops correctly - checking with .Any() returns an error
body: <p>I have a list of <code>Guid</code>, where I keep any duplicate <code>Guid</code> from my list of items:</p>
  
  <pre><code>IEnumerable&lt;Guid&gt; duplicateExists = ListOfMyItems
    .GroupBy(x =&gt; x.ID)
    .Where(group =&gt; group.Count() &gt; 1)
    .Select(group =&gt; group.Key);
  </code></pre>
  
  <p>Now I want to check if duplicate existst, and if so, remove the last occurence of it from <code>ListOfMyItems</code>. <code>DeleteItemFromOrder</code> just deletes a row from database.</p>
  
  <p>This works:</p>
  
  <pre><code> foreach (var item in duplicateExists)
   {                        
       _ = ListOfMyItems.Remove(ListOfMyItems.Last(x =&gt; x.ID == item));
       MyLogic.DeleteItemFromOrder(Bill.ID, item);                      
       return;
   }
  </code></pre>
  
  <p>While this will enter the conditional <code>if</code> and then fail on <code>DeleteItemFromOrder</code>, telling me that <code>duplicateExists - sequence contains no elements</code>:</p>
  
  <pre><code> if(duplicateExists.Any())
   {                        
       _ = ListOfMyItems.Remove(ListOfMyItems.Last(x =&gt; x.ID == duplicateExists.First()));
       MyLogic.DeleteItemFromOrder(Bill.ID, duplicateExists.First());                      
       return;
   } 
  </code></pre>
  
  <p>Why is the 2nd example failing?</p>