title: C# Comparing strings with different case
body: <p>I'm reading a username and then checking to see if exists in another database table, the problem is whilst the username is the same the case maybe different and is preventing it from finding a match example jsmith and JSmith or JSMITH.</p>
  
  <p>How can I fix this? Should I lower the case when writing to the first database or can I alter my code below when I'm comparing the two?</p>
  
  <pre><code>drUser["Enrolled"] = 
      (enrolledUsers.FindIndex(x =&gt; x.Username == (string)drUser["Username"]) != -1);
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>Still struggling with this, the code below compiles but doesn't give the correct result, when viewing enrolled users I see those that aren't enrolled, when viewing those that are not enrolled I see 1 that is enrolled but their username case is the same in each datababse. Have I formatted the code below correctly?</p>
  
  <pre><code>drUser["Enrolled"] = (enrolledUsers.FindIndex(x =&gt; x.Username.Equals((string)drUser["Username"], StringComparison.OrdinalIgnoreCase)));
  </code></pre>
  
  <p>Thanks
  Jamie</p>