??in C # is called the coalescence operator. This is roughly equivalent to the following code
if (total != null) {
return total.Value;
} else {
return Decimal.Zero;
}
if ?? , . ?? total , if .
, total , . , , .
// Here SomeOperation happens twice in the non-null case
if (SomeOperation() != null) {
return SomeOperation().Value;
} else {
return Decimal.Zero;
}
// vs. this where SomeOperation only happens once
return SomeOperation() ?? Decimal.Zero;