更新时间:2023-02-10 18:23:35
假设金额列双(可能是另一种类型)
Assuming the Amount column is a double (could be another type)
double sum = Table.Select(t => t.Amount ?? 0).Sum();
或
double sum = Table.Sum(t => t.Amount ?? 0).Sum();
使用空coelescing接线员会给你的默认值为0,如果t.Amount为null。
Using the null coelescing operator will give you a default of 0 if t.Amount is null.