title: Error : possible unintended reference comparison to get a value comparison cast the right hand
body: <p>I have the following code which gives a warning "possible unintended reference comparison; to get a value comparison, cast the right hand side to type <code>string</code>":</p>
  
  <pre><code>// oControl is of type Control
  if ((ocontrol.Name == oDataRowView["ConName"].ToString()))
  {
     //Do stuff   
  }
  else
  {
     //Do other Stuff
  }
  </code></pre>
  
  <p>I've tried to fix it using each of the following but I still get a warning</p>
  
  <pre><code>if ((ocontrol.Name == Convert.ToString(oDataRowView["ConName"])))
  {
     //Do stuff   
  }
  else
  {
     //Do other Stuff
  }  
  if ((ocontrol.Name == (string)oDataRowView["ConName"]))
  {
     //Do stuff   
  }
  else    
  {
     //Do other Stuff
  }
  </code></pre>
  
  <p>Please could someone explain the reason I still get a warning and the best practice way to deal with this?</p>