A small problem. Any idea guys why this does not work?
int? nullableIntVal = (this.Policy == null) ? null : 1;
I am trying to return null
null
This works: int? nullableIntVal = (this.Policy == null) ? null : (int?)1;.
int? nullableIntVal = (this.Policy == null) ? null : (int?)1;
Reason (copied from comment):
The error message is because the two branches of the ?: operator (null and 1) don't have a compatible type. The branches of the new solution (using null and (int?)1) do.
?:
1
(int?)1