Mid From PDF LINQ LINQ

How to calculate running totals using LINQ?

How to calculate running totals using LINQ?

var salaries = employees.Select(e => e.Salary).ToList();

double runningTotal = 0;

var runningTotals = salaries.Select(s => runningTotal += s);

foreach (var total in runningTotals)

Console.WriteLine(total);

Explanation:

Accumulates sums as you iterate through the sequence.

More from LINQ Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details