C# Nullable Type question
- by TatMing
for example:
int? taxid;
if (ddlProductTax.SelectedValue == "") {
taxid = null; }
else {
taxid = Convert.ToInt32(ddlProductTax.SelectedValue);
} //Correct
But
int? taxid;
taxid = (ddlProductTax.SelectedValue == "" ? null : Convert.ToInt32(ddlProductTax.SelectedValue)); //Error
It error say and int32 cannot implicit convert.
The ( ? truepart : falsepart); is not short of (if ..else..) ?