Collections & LINQ · Lesson 12

Decimal totals

Money stays in decimal, so 0.10 plus 0.20 is 0.30.

How it works

Each literal has an m. Sum adds 0.10m and 0.20m and prints 0.30. Dropping the m would make the literals a different numeric type. For a bill, keep every literal and the array's element type in decimal.

A working example

var parts = new[] { 0.10m, 0.20m };
Console.WriteLine(parts.Sum());

Expected output

0.30
Try this
Try the filter on a smaller list.