Following expression is ok
short d = ("obj" == "obj" ) ? 1 : 2;
But when you use it like below, syntax error occurs
short d = (DateTime.Now == DateTime.Now) ? 1 : 2;
Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?)
Can anyone explain why this is so?
Is there a difference between comparing string-to-string and datetime-to-datetime in a ternary operator, why?
I would be grateful if you could help me.