title: Assign a lambda expression using the conditional (ternary) operator
body: <p>I am trying to use the conditional (ternary) operator to assign the proper lambda expression to a variable, depending on a condition, but I get the compiler error: <em>Type of conditional expression cannot be determined because there is no implicit conversion between 'lambda expression' and 'lambda expression'</em>. I can use the regular if-else to solve this problem, but the conditional operator makes more sense to me (in this context), would make the code more concise add, at least, I would like to know the reasons why it doesn't work. </p>
  
  <pre class="lang-cs prettyprint-override"><code>// this code compiles, but is ugly! :)
  Action&lt;int&gt; hh;
  if (1 == 2) hh = (int n) =&gt; Console.WriteLine("nope {0}", n);
  else hh = (int n) =&gt; Console.WriteLine("nun {0}", n);
  
  // this does not compile
  Action&lt;int&gt; ff = (1 == 2)
    ? (int n) =&gt; Console.WriteLine("nope {0}", n)
    : (int n) =&gt; Console.WriteLine("nun {0}", n);
  </code></pre>