Mid LINQ

How to get employee with maximum salary in a department?

How to get employee with maximum salary in a department?

var maxSalaryInIT = employees

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

Follow :

.OrderByDescending(e => e.Salary)

.FirstOrDefault();

Console.WriteLine($"{maxSalaryInIT?.Name} has the highest salary in

IT");

More from LINQ Tutorial

All questions for this course