title: How can I assign a Func<> conditionally between lambdas using the conditional ternary operator?
body: <p>Generally, when using the conditional operator, here's the syntax:</p>
  
  <pre><code>int x = 6;
  int y = x == 6 ? 5 : 9;
  </code></pre>
  
  <p>Nothing fancy, pretty straight forward.</p>
  
  <p>Now, let's try to use this when assigning a Lambda to a Func type. Let me explain:</p>
  
  <pre><code>Func&lt;Order, bool&gt; predicate = id == null
      ? p =&gt; p.EmployeeID == null
      : p =&gt; p.EmployeeID == id;
  </code></pre>
  
  <p>That's the same syntax, and <em>should</em> work? Right? For some reason that doesn't. The compiler gives this nice cryptic message:</p>
  
  <blockquote>
    <p>Error  1   Type of conditional expression cannot be determined because there is no implicit conversion between 'lambda expression' and 'lambda expression'</p>
  </blockquote>
  
  <p>I then went ahead and changed the syntax and this way it <em>did</em> work:</p>
  
  <pre><code>Func&lt;Order, bool&gt; predicate = id == null
      ? predicate = p =&gt; p.EmployeeID == null
      : predicate = p =&gt; p.EmployeeID == id;
  </code></pre>
  
  <p>I'm just curious as to why it doesn't work the first way?</p>
  
  <p>(Side note: I ended up not needing this code, as I found out that when comparing an int value against null, you just use object.Equals)</p>