overload Equals, is this wrong?
Reading some piece of code and I keep seeing this :
public override bool Equals (object obj)
{
if (obj == null || this.GetType ().Equals (obj.GetType())) return false;
//compare code...
}
Shouldn't it be 开发者_运维知识库like this (note the !):
public override bool Equals (object obj)
{
if (obj == null || !this.GetType ().Equals (obj.GetType())) return false;
//compare code...
}
Or does the equals perform differently in this case?
That looks like a bug. Returning false when the types are the same is certainly not the intended behaviour.
精彩评论