Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are using 4 different methods of comparison, result in different results:</p> <ul> <li>Operator <code>==</code> will by default do a check if the references are equal. In this case you have two instances, so they do have two different references. The behavior of <code>==</code> can overridden by any type (like <code>string</code> has its own method of comparison), but in case of the <code>StringBuilder</code> it is not.</li> <li>Method <code>StringBuilder.Equals(StringBuilder)</code> will compare with another StringBuilder and compares some inside values. These values are, in your case, the same. Strange thing is that <code>StringBuilder</code> does not override the method <code>StringBuilder.Equals(object)</code> to apply the same logic.</li> <li>Method <code>object.Equals(object, object)</code> will try to call the method <code>.Equals(object)</code> of one of the objects. In this case: <code>StringBuilder.Equals(object)</code> which, as I said, did not have the logic to compare the values. Resulting in just a compare of the references of both instances.</li> <li><code>Object.ReferenceEquals</code> will just compare the references.</li> </ul> <p>For more info, see:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/f37cfeys.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/f37cfeys.aspx</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/w4hkze5k.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/w4hkze5k.aspx</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.object.referenceequals.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.object.referenceequals.aspx</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload