namespace Dic
{
public class Key
{
string name;
public Key(string n) { name = n; }
}
class Program
{
static string Test()
{
Key a = new Key(
You need to override the Equals and GetHashCode methods of your Key class. In your case you could compare based on the key's name (or on any other unique property if your class is more complex).
public class Key {
string name;
public Key(string n) { name = n; }
public override bool Equals(object obj) {
Key k = obj as Key;
if (k == null)
return false;
return name.Equals(k.name);
}
public override int GetHashCode() {
return name.GetHashCode();
}
}