Next expression ok
short d = ("obj" == "obj" ) ? 1 : 2;
But when you use it as shown below, a syntax error occurs.
short d = (DateTime.Now == DateTime.Now) ? 1 : 2;
It is not possible to implicitly convert the type 'int' to 'short'. Explicit conversion exists (are you skipping listing?)
Can someone explain why this is so?
Is there a difference between matching strings and strings and datetime-to-datetime in a ternary operator, why?
I would be grateful if you could help me.
casting c # conditional-operator int short
MehmetKasalak Feb 14 '14 at 13:48 2014-02-14 13:48
source share