bool? ispurchased = null;
var pospurcahsed= ispurchased ? \"1\":\"2\";
Its generating exception .
Cannot implicitly con
You can use something like this
bool? chk = false;
//or
bool? chk2 = false;
var test = (chk != null && (bool)chk) ? "1": "2";
//or
var test2 = (chk2.HasValue && (bool)chk2) ? "1" : "2";
I would suggest don't use var keyword for known types.
Instead of this use Like this:
String test = (chk != null && (bool)chk) ? "1" : "2";