Reply to comment

Your reply

You need to sign up / log in to reply to this comment

Existing comment

In your null-coalescing operator examples, this line needs a tweak:

var totalPurchased = PurchaseQuantities.Sum(kvp => kvp.Value ?? 0);

Assuming that kvp is a nullable numeric type (say, Nullable<int>), that line wouldn't compile (CS0019 Operator '??' cannot be applied to operands of type 'int' and 'int').

This would work, though:

var totalPurchased = PurchaseQuantities.Sum(kvp => kvp ?? 0);

Thanks for commenting

Please remember:
Be polite, helpful and keep a positive attitude
Keep it short
Use examples
Review spelling and grammar

Please avoid:
Long texts
Code that is untested
Wall of text