Mid LINQ

How to sum salaries of employees in a department?

How to sum salaries of employees in a department?

var totalSalaryHR = employees

.Where(e => e.Department == "HR")

.Sum(e => e.Salary);

Console.WriteLine($"Total salary in HR: {totalSalaryHR}");

More from LINQ Tutorial

All questions for this course