I'm having a problem when getting the tempkey which is the source loaded from another function. Normally the source contains 18 to 20 keys randomly. This problem happens once in awhile. How to access the source keys without getting exception error like "Collection was modified; enumeration operation may not execute".
private static IDictionary<string, BitArray> source;
public bool Check()
{
string tempKey = source.Keys.FirstOrDefault(k => k.EndsWith(key));
}