Using this class
public class Foo
{
public string c1, c2;
public Foo(string one, string two)
{
c1 = one;
c2 = two;
}
pu
You need to override the equals method as well. The reason for this is that the hashcode is allowed to collide for two objects that is not equal. Otherwise it won't work.
public override bool Equals(Object obj)
{
Foo otherObject = obj as Foo;
return otherObject != null && otherObject.c1 == this.c1 && otherObject.c2 == this.c2;
}