title: C# Inline lambda evaluation
body: <p>At various times while programming in C# I've found myself in situations where I'd like to define a lambda (or anonymous delegate) and call it in the same line.  At this point, the 'cleanest' way I've been able to do this is like this:</p>
  
  <pre><code>bool foo_equals_bar = new Func&lt;String, bool&gt;(str =&gt; str.Equals("foo"))("bar");
  </code></pre>
  
  <p>I would love to be able to do write something like the following instead:</p>
  
  <pre><code>bool foo_equals_bar = (str =&gt; str.Equals("foo"))("bar");
  </code></pre>
  
  <p>Unfortunately, this doesn't seem to work.  I would love to know:</p>
  
  <ol>
  <li>Is there a simpler way of writing the line of code above?</li>
  <li>What is returned from <code>(str =&gt; str.Equals("foo"))</code> such that is can be used to initialize a <code>Func&lt;String, bool&gt;</code>, but can not be evaluated like a <code>Func&lt;String, bool&gt;</code>?</li>
  </ol>
  
  <p>I should point out that I'm working in C# 3 (VS2008), so if a solution only exists in C# 4, please mention that. (I'd still like to know, even if the solution isn't available to me at the moment).</p>
  
  <p>Thanks</p>