This works:
short value;
value = 10 > 4 ? 5 : 10;
This works:
short value;
value = "test" == "test" ? 5 : 10;
This doesn't work:
short value;
string str = "test";
value = "test" == str ? 5 : 10;
Neither does this:
short value;
string str = "test";
value = "test".Equals(str) ? 5 : 10;
The last two cases I am getting the following error:
Cannot implicitly convert type 'int' to 'short'.
An explicit conversion exists (are you missing a cast?)
Why do I have to cast on the last two cases and not on the two first cases?