Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private static void AggregateDemo(List<Order> orders)
{
const int initialQuantity = 0;
var totalQuantities = orders.Aggregate(initialQuantity, (sum, order) => sum + order.Quantity);
// Same as Order simply use a convinient `Sum()` method.
// var totalQuantities = orders.Sum(order => order.Quantity);
System.Console.WriteLine($"Total Quantities: {totalQuantities}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.