title: Comparing two objects with == operator
body: <p>I have this code that checks the references of two variables,
  I came across this case which is a bit confusing :</p>
  <pre class="lang-cs prettyprint-override"><code>string first = &quot;10&quot;;
  object second = 10.ToString();
  dynamic third = second;
  
  Console.WriteLine($&quot;{first == second}   {first == third}&quot;);
  </code></pre>
  <p>The result is : <code>False   True</code></p>
  <p>My first question is why are the first and third references equal? If the third variable is equal to the second it should be <code>False</code> because their object references aren't equal.</p>
  <p>And I got confused when I changed the values to <code>&quot;1&quot;</code> like below:</p>
  <pre class="lang-cs prettyprint-override"><code>string first = &quot;1&quot;;
  object second = 1.ToString();
  dynamic third = second;
  
  Console.WriteLine($&quot;{first == second}   {first == third}&quot;);
  </code></pre>
  <p>Then the result becomes: <code>True     True</code></p>
  <p>Why does this happen?</p>