title: How to ignore whitespaces on string comparison?
body: <p>I have list of strings. At some point I need to check if list contains some string.</p>
  
  <p>For example:</p>
  
  <pre><code>  public List&lt;string&gt; Headers { get; private set; }
  
    Headers = new List&lt;string&gt;();
    Headers.Add("bla1 bla1 ");// pay attention to the whitespace at the end
    Headers.Add("bla2 bla2");
    Headers.Add("bla3 bla3");
    Headers.Add("bla4 bla4");
  </code></pre>
  
  <p>At some point I need to check if list of string contains for example <code>"bla1 bla1"</code> string.  </p>
  
  <p>For this purpose I use this line of code:</p>
  
  <pre><code>var isExists = Headers
      .Where(h =&gt;!h.Equals("bla1 bla1", StringComparison.InvariantCultureIgnoreCase)
  </code></pre>
  
  <p>But the result of <code>isExists</code> variable is false because headers contains <code>"bla1 bla1"</code> string with a space at the end.</p>
  
  <p>How can I ignore <code>whitespaces</code> at the start and at the end of the string? </p>