title: Why String.Equals is returning false?
body: <p>I have the following C# code (from a library I'm using) that tries to find a certificate comparing the thumbprint. Notice that in the following code both <code>mycert.Thumbprint</code> and <code>certificateThumbprint</code> are strings.</p>
  
  <pre><code>var certificateThumbprint = AppSettings.CertificateThumbprint;
  
  var cert =
      myStore.Certificates.OfType&lt;X509Certificate2&gt;().FirstOrDefault(
        mycert =&gt; 
        mycert.Thumbprint != null &amp;&amp; mycert.Thumbprint.Equals(certificateThumbprint)
        );
  </code></pre>
  
  <p>This fails to find the certificate with the thumbprint because <code>mycert.Thumbprint.Equals(certificateThumbprint)</code> is <code>false</code> even when the strings are equal. <code>mycert.Thumbprint == certificateThumbprint</code> also returns <code>false</code>, while <code>mycert.Thumbprint.CompareTo(certificateThumbprint)</code> returns 0. </p>
  
  <p><img src="https://i.stack.imgur.com/j13lM.png" alt="enter image description here"></p>
  
  <p>I might be missing something obvious, but I can't figure out why the <code>Equals</code> method is failing. Ideas?</p>