/// <summary> /// Remove entries from dictionary that match the removeCondition. /// </summary> public static void RemoveFromDictionary <TKey, TValue>(this IDictionary <TKey, TValue> dictionary, Func <KeyValuePair <TKey, TValue>, bool> removeCondition) { // Pass the delegate as the state to avoid a delegate and closure dictionary.RemoveFromDictionary((entry, innerCondition) => { return(innerCondition(entry)); }, removeCondition); }