http://code>IEquatable<T>Equals(T obj) do when this = = 无
和obj = 无
?
1) This code is generated by F# compiler when implementing IEquatable<T>
. You can see that it returns true
when both objects are null
:
public sealed override bool Equals(T obj) { if (this == null) { return obj == null; } if (obj == null) { return false; } // Code when both this and obj are not null. }
2) Similar code can be found in the question "in IEquatable implementation is reference check necessary" or in the question "Is there a complete IEquatable implementation reference?". This code returns false
when both objects are null
.
public sealed override bool Equals(T obj) { if (obj == null) { return false; } // Code when obj is not null. }
<>3> 最后一个选择是说,在<代码>this=0时,该方法的行为没有界定。