title: How add or remove object while iterating Collection in C#
body: <p>I am trying to remove object while I am iterating through Collection. But I am getting exception. How can I achieve this?
  Here is my code :</p>
  
  <pre><code>foreach (var gem in gems)
  {
      gem.Value.Update(gameTime);
  
      if (gem.Value.BoundingCircle.Intersects(Player.BoundingRectangle))
      {
         gems.Remove(gem.Key); // I can't do this here, then How can I do?
         OnGemCollected(gem.Value, Player);
      }
  }
  </code></pre>