I try to
Collection.Aggregate(0.0,(current, next) => current += next.decimalValue);
but I get error of casting decimal to double
another issue: For "Sum" Linq the seed is the default type value? meaning seed = 0 for decimal...
The compiler interprets 0.0 as a double, you need to specify the type as a decimal. Try the following:
Collection.Aggregate(0m, (current, next) => current += next.decimalValue);
The m suffix indicates that the numeric real literal (in this case 0) is a decimal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With