C# Distinct List from a List
This question already has an answer here:
You can either use GroupBy
with an anonymous type as a key:
occupancyResultList = occupancyResultList
.GroupBy(x => new { x.on_date, x.type_code, x.available })
.Select(g => g.First())
.ToList();
Or DistinctBy
method:
occupancyResultList = occupancyResultList
.DistinctBy(x => new { x.on_date, x.type_code, x.available })
.ToList();
链接地址: http://www.djcxy.com/p/51296.html
上一篇: 使用linq独特的功能?
下一篇: 来自列表的C#不同列表