C# Foundations · Lesson 10

Parameters

A parameter is the name a caller fills in.

How it works

Where walks the array and calls the lambda once per price. The parameter p is 12, then 8, then 25. p >= 10m keeps 12 and 25 and drops 8. Sum adds only the kept values, so the printed total is 37.

A working example

using System.Linq;

var prices = new[] { 12m, 8m, 25m };

var total = prices
    .Where(p => p >= 10m)
    .Sum();

Console.WriteLine(total);

Expected output

37
Try this
p stands for one price at a time.