Why GetHashCode() matters?
<p>Hi all
Im trying to understand what the object.GetHashCode(), is used for, i read that it is used by collections to uniquely identify keys. But i wanted to test this and the result isnt what i expected.</p>

<pre><code>struct Animal
{
    public string Name { get; set; }
    public int Age { get; set; }

    public Animal(string name, int age) : this()
    {
        Name = name;
        Age = age;
    }

    public override int GetHashCode()
    {
        return Age.GetHashCode();
    }
}

object doggy = new Animal("Dog", 25);
object cat = new Animal("Cat", 25);

Hashtable table = new Hashtable();
table.Add(doggy, "Dog");
table.Add(cat, "Cat");

Console.WriteLine("{0}", table[cat]);
Console.WriteLine("{0}", table[doggy]);
</code></pre>

<p>I Would have expected "Cat" would overwrite "Dog" or somekind error telling me that "key already exists" but the output is </p>

<p>"Cat"
"Dog"</p>
