namespace Dic { public class Key { string name; public Key(string n) { name = n; } } class Program { static string Test() { Key a = new Key(
ContainsKey in this case is comparing Key as objects and checking to see if the objects themselves are the same -- they are not. You need to implement IComparable or override Key.Equals or something along those lines to get it to do what you want.