0
獲取頂級最大項考慮:通過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。我怎樣才能做到這一點?
獲取頂級最大項考慮:通過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);
此代碼甚至不進行編譯。你的意思是排名前5的最大Avd而不是AVG? – DavidG 2015-02-08 18:44:42