Why does String.Equals(Object obj) check to see if this == null? [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Why check this != 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