I have to remove items from ConcurrentDictionary by some keys. Like this:
ConcurrentDictionary<SomeClass, string> dict = new ConcurrentDictionary<SomeClass, string>();
//adding some values
var keys = dict.Keys.Where(k => k.Name == "Example");
foreach (var key in keys)
dict.TryRemove(key, out _);
The question is: I am enumerating the keys collection when is start looping. What if somebody will change the dict at the same time? Does dict.Keys returns a snapshot?