would remove a key from Dictionary in foreach cause a problem? or should I better to construct a new Dictionary?
<p>for example:</p>

<p>1.</p>

<pre><code>         foreach (var item in myDic)
                {
                  if (item.value == 42)
                        myDic.remove(item.key);
                }
</code></pre>

<p>would the iterator works properly no matter how the statements in the inner brackets could possibly affect <code>myDic</code>?</p>

<p>2.</p>

<pre><code>    var newDic = myDic.where(x=&gt;x.value!=42).ToDictionary(x=&gt;x.key,x=&gt;x.value);
</code></pre>

<p>Is 2nd approach a good practice? functional programming and immutable?</p>
