title: String comparison performance in C#
body: <p>There are a number of ways to compare strings. Are there performance gains by doing one way over another?</p>
  
  <p>I've always opted to compare strings like so:</p>
  
  <pre><code>string name = "Bob Wazowski";
  if (name.CompareTo("Jill Yearsley") == 0) {
      // whatever...
  }
  </code></pre>
  
  <p>But I find few people doing this, and if anything, I see more people just doing a straight == comparison, which to my knowledge is the worst way to compare strings. Am I wrong?</p>
  
  <p>Also, does it make a difference in how one compares strings within LINQ queries? For example, I like to do the following:</p>
  
  <pre><code>var results = from names in ctx.Names
                where names.FirstName.CompareTo("Bob Wazowski") == 0
                select names;
  </code></pre>
  
  <p>But again, I see few people doing string comparisons like so in their LINQ queries.</p>