This is because by default it tests the same link. In this case, you have two instances of the object, so they are not "equal."
If you want to change this behavior, you just need to implement the IEquatable<T> interface, and you can override what Equals() will return. For instance:
public bool Equals(YourClass other) { return (this.Value == other.Value); }
For a good reference to Object.Equals() see this link on MSDN . Equality for reference types is based on their reference. That is, if they do not refer to the same object, then Equals() will return false .
user596075
source share