title: Passing in an anonymous method/function as a parameter in C#
body: <p>I have a method that needs to conditionally execute a method, something like this:</p>
  
  <pre><code>int MyMethod(Func&lt;int&gt; someFunction)
  {
      if (_someConditionIsTrue)
      {
          return someFunction;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I want to be able to pass a Linq query in to MyMethod as someFunction:</p>
  
  <pre><code>int i = MyMethod(_respository.Where(u =&gt; u.Id == 1).Select(u =&gt; u.OtherId));
  </code></pre>
  
  <p>How do I do this?</p>