This is my list:
List<int> numbers=new List<int> { 12, 5, -8, 4, 7, 28, 3, 22 };
How can I get 4 maximum numbers by lambda: I need these ones: {28, 22, 12, 7}
This is my list:
List<int> numbers=new List<int> { 12, 5, -8, 4, 7, 28, 3, 22 };
How can I get 4 maximum numbers by lambda: I need these ones: {28, 22, 12, 7}
Use:
var result = numbers.OrderByDescending(n => n).Take(4);