title: Different behaviour when collection modified between Dictionary and ConcurrentDictionary
body: <p>With a normal Dictionary code as list below, I get exception that </p>
  
  <blockquote>
    <p>Collection was modified; enumeration operation may not execute.</p>
  </blockquote>
  
  <pre><code>Dictionary&lt;int, int&gt; dict2 = new Dictionary&lt;int, int&gt;();
  dict2.Add(1, 10);
  dict2.Add(2, 20);
  dict2.Add(3, 30);
  dict2.Add(4, 40);
  
  foreach (var d in dict2)
  {
      if (dict2.ContainsKey(2))
          dict2.Remove(2);
  
      if (dict2.ContainsKey(3))
          dict2.Remove(3);
  }
  </code></pre>
  
  <p>However with ConcurrentDictionary, this works fine.</p>
  
  <pre><code>ConcurrentDictionary&lt;int, int&gt; dict1 = new ConcurrentDictionary&lt;int, int&gt;();
  dict1.AddOrUpdate(1, 10, (k,v)=&gt; 10);
  dict1.AddOrUpdate(2, 20, (k, v) =&gt; 20);
  dict1.AddOrUpdate(3, 30, (k,v)=&gt; 30);
  dict1.AddOrUpdate(4, 40, (k,v)=&gt; 40);
  
  foreach (var d in dict1)
  {
      int x;
      if (dict1.ContainsKey(2))
          dict1.TryRemove(2, out x);
  
      if (dict1.ContainsKey(3))
          dict1.TryRemove(3, out x);
  }
  </code></pre>
  
  <p>Why there is difference in behaviour?</p>