我有一个名为发票列表的列表,其中包含以下项目。
ID:1
Total:5
Description:Test
Date:2012-01-01
Difference:
ID:2
Total:10
Description:Test
Date:2012-02-01
Difference:
ID:3
Total:15
Description:Test
Date:2012-03-01
Difference:
ID:4
Total:20
Description:Test
Date:2012-04-01
Difference:
我需要使用 LINQ 计算每个发票 ID 之间的差异(最好)。最终输出应如下所示:
ID:1
Total:5
Description:Test
Date:2012-01-01
Difference:0
ID:2
Total:10
Description:Test
Date:2012-02-01
Difference:5
ID:3
Total:15
Description:Test
Date:2012-03-01
Difference: 5
ID:4
Total:20
Description:Test
Date:2012-04-01
Difference:5
有人可以建议实现上述目标的最佳方法吗?