title: C# String comparison fails for string having special character in it
body: <p>I have a list of string that contains few strings with some special characters like -, [, ], (, ).</p>
  
  <p>I am passing a string to a method where I need to parse the above list &amp; find if the exact match is found or not. </p>
  
  <p>For this I have written the below code, but when ever the special characters are present in the string, its not able to compare. </p>
  
  <pre><code>foreach (var item in myList)
  {
      if (myInput.Trim().ToUpper() == item.Trim().ToUpper() ) //Here myInput is "In - Com [SP]"
      {
          count++;
      }
  
  }
  </code></pre>
  
  <p>But if I compare a static string by a preceding @ symbol, then the compare is working fine. For Example :</p>
  
  <pre><code>if (item == @"In - Com [SP]")
  {
      count++;
  }
  </code></pre>
  
  <p>Can anyone please help me how to incorporate this for a dynamic list of strings? 
  NB : We cant concatenate @ with a string variable. </p>
  
  <p>Any ways exist by using Regex?  </p>