有人可以解释一下下面的代码return total ?? decimal.Zero
吗?
public decimal GetTotal()
{
// Part Price * Count of parts sum all totals to get basket total
decimal? total = (from basketItems in db.Baskets
where basketItems.BasketId == ShoppingBasketId
select (int?)basketItems.Qty * basketItems.Part.Price).Sum();
return total ?? decimal.Zero;
}
是以下的意思吗?
if (total !=null) return total;
else return 0;