fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. class Employee
  5. {
  6. public string Name { get; set; }
  7. public decimal Salary { get; set; }
  8. }
  9.  
  10. public class Test
  11. {
  12. public static void Main()
  13. {
  14. Employee[] emps = new Employee[]
  15. {
  16. new Employee { Name = "John", Salary = 9 },
  17. new Employee { Name = "Paul", Salary = 8 },
  18. new Employee { Name = "George", Salary = 6 },
  19. new Employee { Name = "Ringo", Salary = 6 }
  20. };
  21. decimal minSalary = emps.Min(x => x.Salary);
  22.  
  23. foreach(var e in emps.Where(e => e.Salary == minSalary))
  24. Console.WriteLine("{0} {1}", e.Name, e.Salary);
  25. }
  26. }
Success #stdin #stdout 0.03s 38056KB
stdin
1
2
10
42
11
stdout
George 6
Ringo 6