If you use:
foreach ( string key in dictionary.Keys ) {
if( badKey.contains( key ) ) {
dictionary.Remove( key );
}
}
The code will fail with the error "Collection was modified; enumeration operation may not execute". I am searching for a way to do this but haven't found one yet. Any ideas?