重複の可能性:
なぜこれをチェックするのですか!= null?
// Determines whether two strings match.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public override bool Equals(Object obj)
{
//this is necessary to guard against reverse-pinvokes and
//other callers who do not use the callvirt instruction
if (this == null)
throw new NullReferenceException();
String str = obj as String;
if (str == null)
return false;
if (Object.ReferenceEquals(this, obj))
return true;
return EqualsHelper(this, str);
}
私が理解していない部分は、現在のインスタンスthis
をnullに対してチェックしているという事実です。コメントは少し紛らわしいので、そのコメントは実際にはどういう意味なのか疑問に思いました。
そのチェックがなかった場合にこれがどのように壊れるかの例を誰かが挙げることができますか?これは、そのチェックをクラスに配置する必要があることを意味しますか?