Custom key class for .NET 3.5 framework
Mutable keys are a very bad idea, try this:

public void Foo()
{
    var mutable = new Mutable { Value = 1 };
    var dictionary = new Dictionary&lt;Mutable, string&gt; { { mutable, "one" } };
    mutable.Value = 2;
    var explodesHere = dictionary[mutable];
}

public class Mutable
{
    public int Value;

    public override int GetHashCode()
    {
        return Value;
    }
}

GetHashCode must not change while the instance is used in a collection that relies on the value. There are two ways to solve this:


Calculate the hash from values that cannot change. Prefer this wherever possible.
Make sure that the values affecting the hash are not changed while the instance is used in a collection. This is a pit of failure.






You can create a dictionary passing in an IEqualityComparer&lt;TKey&gt;
About your example:

ID reads like a property that uniquely identifies an entity and does not change.
If this is the case it is a nice candidate to use as a key. I'm guessing a bit here but I'm getting a feeling you really want:

var idNameMap = new Dictionary&lt;int, string&gt;();
idNameMap.Add(t1.ID, t1.Name);