我有2个不同类型的列表,我想按日期分组,然后合并每个日期的2个列表。合并2个不同类型的列表为1
我的2清单看起来像这样。
List<Payment> payments = new List<Payment>
{
new Payment{Date = '2014-01-01 12:23:52', PaymentSum = 300},
new Payment{Date = '2014-01-01 12:23:53', PaymentSum = 100},
new Payment{Date = '2014-01-02 12:23:52', PaymentSum = 300},
}
List<Invoice> invoices = new List<Invoice>
{
new Invoice{Date = '2014-01-01 12:20:32', InvoiceSum= 300},
new Invoice{Date = '2014-01-01 12:21:53', InvoiceSum= 200},
new Invoice{Date = '2014-01-02 12:24:52', InvoiceSum= 300},
}
我想结果是这个样子:提前
List<NewItem> newItems= new List<NewItem>
{
new NewItem{Date = '2014-01-01', InvoiceSum= 500, PaymentSum = 400},
new NewItem{Date = '2014-01-02', InvoiceSum= 300, PaymentSum = 300},
}
谢谢!
你有试过什么吗? – Andrei 2015-02-10 11:48:24