I have a Dictionary which I am comparing to another Dictionary (variables typed as IDictionary). Doing d1.Equals(d2) yields false. Writing my own code below yields true. Both are System.Collections.Generic.Dictionary. Am I missing something or does Dictionary not have an Equals implementation that compares keys/values?
private static bool DictEquals<K, V>(IDictionary<K, V> d1, IDictionary<K, V> d2) { if (d1.Count != d2.Count) return false; foreach (KeyValuePair<K, V> pair in d1) { if (!d2.ContainsKey(pair.Key)) return false; if (!Equals(d2[pair.Key], pair.Value)) return false; } return true; }