![](/img/trans.png)
[英]Linq - OrderByDescending and Take(1), will it return max item?
[英]Get top max item by linq
考慮:
public class student
{
public int Avd{get;set;}
}
並且主要:
list<student> Students =new List<student>{2,3,6,1,20,12,45};
我想通過linq獲得《學生》雜志的前5個最大AVG。 我怎樣才能做到這一點?
Students = Students.OrderByDescending(x=>x.Avd).Take(5).ToList();
根據Avg
順序對列表進行降序排序,然后使用Take
獲取”獲取5名學生:
Students.OrderByDescending(s => s.Avg).Take(5);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.