Object.ReferenceEquals

https://msdn.microsoft.com/en-us/library/system.object.referenceequals(v=vs.110).aspx

However, the return value of the ReferenceEquals method may appear to be anomalous in these two scenarios:

1. When comparing value types. If objA and objB are value types, they are boxed before they are passed to the ReferenceEquals method. This means that if both objA and objB represent the same instance of a value type, the ReferenceEquals method nevertheless returns false, as the following example shows.

2. When comparing strings. If objA and objB are strings, the ReferenceEquals method returns true if the string is interned. It does not perform a test for value equality. In the following example, s1 and s2 are equal because they are two instances of a single interned string. However, s3 and s4 are not equal, because although they are have identical string values, that string is not interned.

原文地址:https://www.cnblogs.com/lilei9110/p/5073864.html