Dictionary(TKey, TValue) GetHashCode and Equals - How do they work?
<p>You would think that if two dictionaries contained the same keys and values they would return the same hash code and be equal right? but they don't - what am i doing wrong? or how do I compare dictionaries in this way?</p>

<p>Thanks. Code sameple below</p>

<p>/In this case I also want to test the order is the same/equal.</p>

<pre><code>     SortedDictionary&lt;int,string&gt; sd1 = new SortedDictionary&lt;int,string&gt;();
        sd1.Add(1,"one");
        sd1.Add(2, "two");
        sd1.Add(5, "five");
        int sd1Hash = sd1.GetHashCode();

        SortedDictionary&lt;int, string&gt; sd2 = new SortedDictionary&lt;int, string&gt;();
        sd2.Add(1, "one");
        sd2.Add(2, "two");
        sd2.Add(5, "five");
        int sd2Hash = sd2.GetHashCode();

        //This is false
        bool areEqual = sd1.Equals(sd2);
</code></pre>
