Deleting while iterating over a dictionary
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2347269/modifying-net-dictionary-while-enumerating-through-it">Modifying .NET Dictionary while Enumerating through it</a>  </p>
</blockquote>



<p>i have a dictionary object when i iterate over and do some operations. Based on a condition i should either delete or keep the keyvalue pair i am currently iterating over. What is the best way to delete a keyvaluepair from a dictionary while iterating over it? I tried to use a separate dictionary object to keep track of the elements to delete but im not sure how to then use it to delete from my main dictionary or if thats even the most efficient way to do it</p>

<p>Thanks</p>
