title: C# - Pass function to derive object property as argument
body: <p>I'd like to make this function more generic by specifying the property of Foo that I search on in the function arguments. At the moment I have to have a function for every property of Foo rather than just one generic function.  </p>
  
  <pre><code>private Func&lt;Foo, bool&gt; ByName(bool _exclude, string[] _searchTerms)
  {
      if (_exclude)
      {
          return x =&gt; !_searchTerms.Contains( x.Name.Replace(" ", "").ToLower() );
      }
  
      return x =&gt; _searchTerms.Contains( x.Name.Replace(" ", "").ToLower() );
  }
  </code></pre>
  
  <p>Is it possible to make this function more generic to be able to pass the search property of Foo?   </p>