【发布时间】:2019-08-14 17:24:18
【问题描述】:
我有一个名为 reportData 的对象,它保存报告的数据。
这个对象是类型
List<Dictionary<string, string>>
我需要添加逻辑来操作reportData,即当键“Type”的值为Withdrawal 时,键“TransAmount”的值之前应该有一个减号。
我在想我可以用一些 linq 来完成这个,但我没有任何成功。
这是我迄今为止尝试过的......
foreach (var kvp in reportData.SelectMany(m => m).Where(x => x.Value != null))
{
if (kvp.Value.Equals("Deposit"))
(
//Over here I need to set the value of the key "TransAmount" to have a minus sign before it, but I'm not sure how to go about it
)
}
这里是reportData 中保存的数据的快照。列表中展示的项目属于“提款”类型,我的代码需要处理列表中属于“存款”类型的项目
【问题讨论】: