for example:
1.
foreach (var item in myDic) { if (item.value == 42) myDic.remove(item.
Also you can iterate over the copy of your collection:
foreach (var item in myDic.ToList()) { if (item.value == 42) myDic.remove(item.key); }
notice myDic.ToList() in foreach statement.
myDic.ToList()
foreach