C# conditional operator ?: has problems with nullable int
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/75746/conditional-operator-assignment-with-nullablevalue-types">Conditional operator assignment with Nullable&lt;value&gt; types?</a>  </p>
</blockquote>



<p>Why does the conditional operator “?:” not work here when my function is returning a nullable integer “int?”?  “return null” works but with “?:” I have to cast “null” to “(int?)” first.</p>

<pre><code>    public int? IsLongName(string name) {

        int length = name.Length;

        // this works without problems
        if (name.Length &gt; 10) {
            return null;
        } else {
            return name.Length;
        }

        // this reports: 
        // Type of conditional expression cannot be determined because 
        // there is no implicit conversion between '&lt;null&gt;' and 'int'
        return name.Length &gt; 10 ? null : name.Length;
    }
</code></pre>
