<分区>
我有对象列表 List<Payment>
.我想获得按 PaymentDate
分组的列表列表.类似的东西:List<List<Payments>>
其中列表的每个列表都有相同的日期(没有时间)。
<分区>
我有对象列表 List<Payment>
.我想获得按 PaymentDate
分组的列表列表.类似的东西:List<List<Payments>>
其中列表的每个列表都有相同的日期(没有时间)。
最佳答案
DateTime
有一个 Date
property :
List<List<Payments>> result = payments
.GroupBy(p => p.PaymentDate.Date)
.Select(g => g.ToList())
.ToList();
关于c# - LINQ 按日期将列表拆分为列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20254035/