Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有list<result>具有这些属性 { person, score, regdate} 的结果对象。而且我只想从每个人中选择第一个注册分数(所以我为每个人得到一个结果,即使这个人有更多结果)。
list<result>
person
score
regdate
我需要这个,所以我可以用它们来为第一次结果做一个平均分。
如果您的初始结果列表是:
List<Result> results=...
然后你可以这样做:
var scores = results .GroupBy(r => r.person.Id) .Select(g => g .OrderBy(res=>res.regdate) .First() );