How to find the top N highest paid employees?
How to find the top N highest paid employees?
int topN = 3;
var topEarners = employees
.OrderByDescending(e => e.Salary)
.Take(topN);
foreach (var emp in topEarners)
Console.WriteLine($"{emp.Name}: {emp.Salary}");
Explanation:
Orders employees by salary descending and takes the top N.