Problem using Conditional Operation with Nullable Int
Posted
by Rajarshi
on Stack Overflow
See other posts from Stack Overflow
or by Rajarshi
Published on 2010-05-21T10:45:41Z
Indexed on
2010/05/21
10:50 UTC
Read the original article
Hit count: 192
c#
A small problem. Any idea guys why this does not work?
int? nullableIntVal = (this.Policy == null) ? null : 1;
I am trying to return 'null' if the left hand expression is True, else 1. Seems simple but gives compilation error -
Type of conditional expression cannot be determined because there is no implicit conversion between 'null' and 'int'
If I replace the " ? null : 1 " with any valid int, then there is no problem.
© Stack Overflow or respective owner