title: Difference between C# and Java's ternary operator (? :)
body: <p>I am a C# newbie and I just encounter a problem. There is a difference between C# and Java when dealing with the ternary operator (<code>? :</code>).</p>
  
  <p>In the following code segment, why does the 4th line not work? The compiler shows an error message of <code>there is no implicit conversion between 'int' and 'string'</code>. The 5th line does not work as well. Both <code>List</code>s are objects, aren't they?</p>
  
  <pre><code>int two = 2;
  double six = 6.0;
  Write(two &gt; six ? two : six); //param: double
  Write(two &gt; six ? two : "6"); //param: not object
  Write(two &gt; six ? new List&lt;int&gt;() : new List&lt;string&gt;()); //param: not object
  </code></pre>
  
  <p>However, the same code works in Java:</p>
  
  <pre><code>int two = 2;
  double six = 6.0;
  System.out.println(two &gt; six ? two : six); //param: double
  System.out.println(two &gt; six ? two : "6"); //param: Object
  System.out.println(two &gt; six ? new ArrayList&lt;Integer&gt;()
                     : new ArrayList&lt;String&gt;()); //param: Object
  </code></pre>
  
  <p>What language feature in C# is missing? If any, why is it not added?</p>