title: Possible unintended reference comparison
body: <p>I have the following code which gives a warning</p>
  
  <blockquote>
    <p>Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'`</p>
  </blockquote>
  
  <pre><code>if (lblStatus.Content == "ACTIVE")
  {
    //Do stuff
  }
  else
  {
    //Do other Stuff
  }
  </code></pre>
  
  <p>I'm assuming the warning is because <code>lblStatus.Content</code> may not necessarily always be of type string?</p>
  
  <p>I've tried to fix it using each of the following but I still get a warning</p>
  
  <pre><code>if (lblStatus.Content.ToString() == "ACTIVE")
  if ((string)lblStatus.Content == "ACTIVE")
  if (lblStatus.Content === "ACTIVE")
  </code></pre>
  
  <p>Please could someone explain the reason I still get a warning and the best practical way to deal with this?</p>