I have a class with an integer property. I have a list of them that are to be used in a charting application. I want to display this property as a cumulative total, while retaining all of the other class information.
Let’s call this class ProgressMeasurement and the property is OutstandingItems. Is there some method, using the Aggregate function where I can accomplish this?
For example:
progressMeasurementList.Aggregate((a, b) => b.OutstandingItems += a.OutstandingItems));
i.e. I want to update b‘s OutstandingItems value to be the current running total.
Cheers
There’s nothing built in but you can create your own extension method:
You can then calculate a sequence of cumulative sums as: