Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2018 22:43
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