Using this class
public class Foo
{
public string c1, c2;
public Foo(string one, string two)
{
c1 = one;
c2 = two;
}
public override int GetHashCode()
{
return (c1 + c2).GetHashCode();
}
}
And this HashSet
HashSet<Foo> aFoos = new HashSet<Foo>();
Foo aFoo = new Foo("a", "b");
aFoos.Add(aFoo);
aFoos.Add(new Foo("a", "b"));
label1.Text = aFoos.Count().ToString();
I get the answer 2, when surely it should be 1. Is there a way to fix this so my HashSet contains only unique objects?
Thanks, Ash.