namespace Dic
{
public class Key
{
string name;
public Key(string n) { name = n; }
}
class Program
{
static string Test()
{
Key a = new Key(
you problem is that
new Key("A").Equals(new Key("A"))==false.
and
new Key("A").GetHashCode()!=new Key("A").GetHashCode()
fix that and it should work I think. To fix it override the Equals method and check if the name values are the same. You should also override GetHashCode if you are overriding Equals.