No implicit int -> short conversion in ternary statement
问题 short s; s = (EitherTrueOrFalse()) ? 0 : 1; This fails with: error CS0266: Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) Can anyone explain why this is so? The only thing I can think of is that the compiler doesn't look at the second value and doesn't know the range between the two, in the case I wrote something like short s; s = (EitherTrueOrFalse()) ? 0 : 65000; Correct? The only fix is with an ugly cast? Also, it seems C# does not