title: How to override functions from String class in C#
body: <p>For example, I need to see if a string contains a substring, so I just do:</p>
  
  <pre><code>String helloworld = "Hello World";
  if(helloworld.Contains("ello"){
      //do something
  }
  </code></pre>
  
  <p>but if I have an array of items</p>
  
  <pre><code>String helloworld = "Hello World";
  String items = { "He", "el", "lo" };
  </code></pre>
  
  <p>I needed to create a function inside the String class that would return true if either of
  the items inside the array is contained in the string, for example.</p>
  
  <p>I would like to override the function Contains(string) with Contains(IEnumerable) for this scenario, instead of creating a function in another class. Is it possible to do this, and if so, how can we override the function? Thank you very much.</p>
  
  <p>So here goes the complete solution (thanks guys):</p>
  
  <pre><code>public static bool ContainsAny(this string thisString, params string[] str) {
      return str.Any(a =&gt; thisString.Contains(a));
  }
  </code></pre>