title: Removing characters from strings with LINQ
body: <p>I'm trying to brush up on my LINQ by writing some simple extension methods. Is there any better way to write such a function as below that removes a given list of characters from a string (using LINQ)? </p>
  
  <p>It helps me to think of the extension methods that LINQ relies on first:</p>
  
  <pre><code>public static string Remove(this string s, IEnumerable&lt;char&gt; chars)
  {
      string removeChars = string.Concat(chars);
  
      return new string(s.ToCharArray().Where(c =&gt; !removeChars.Contains(c)).ToArray());
  }
  </code></pre>
  
  <p>But that's pretty ugly. Ergo LINQ.</p>
  
  <p><strong>The difference that I notice in the LINQ statement is that I have to use 'select' whereas with the extension method, I don't have to.</strong></p>
  
  <pre><code>/// &lt;summary&gt;Strip characters out of a string.&lt;/summary&gt;
  /// &lt;param name="chars"&gt;The characters to remove.&lt;/param&gt;
  public static string Remove(this string s, IEnumerable&lt;char&gt; chars)
  {
      string removeChars = string.Concat(chars);
  
      var stripped = from c in s.ToCharArray()
                     where !removeChars.Contains(c)
                     select c;
  
      return new string(stripped.ToArray());
  }
  </code></pre>
  
  <p>So I'm wondering if this (last snippet above) is the tersest LINQ statement to accomplish removal of characters.</p>