title: removing items from a generic List<t>
body: <p>I have the following method, I wish to remove items from my collection that match the product Id. Seems fairly straight forward, but i get an exception. Basically my collection is getting out of sync. So what is the best way to remove an item from a collection. </p>
  
  <pre><code>public void RemoveOrderItem(Model.Order currentOrder, int productId)
  {
  
      foreach (var orderItem in currentOrder.OrderItems)
      {
          if (orderItem.Product.Id == productId)
          {
              currentOrder.OrderItems.Remove(orderItem);
          }
      }
  }
  </code></pre>
  
  <p>Exception Details: System.InvalidOperationException: Collection was modified; enumeration operation may not execute</p>