The Contains method uses the Equals on object, and it just checks that the memory addresses are different.
Think about changing your class to this ...
class Bind : IEquatable<Bind> {
public string x { get; set; }
public string y { get; set; }
public bool Equals(Bind other)
{
return x == other.x && y == other.y;
}
}
Your loop then visits the strongly typed Equals method in your class, and this will lead to the behavior you are after.
NOTE: the string class ALSO inherits from IEquatable from T, and this is what allows the equality operator to work with the contents of the string rather than the address of the string.
source
share