Created
February 24, 2018 22:43
-
-
Save dance2die/6dfb6a38bc0faaa74f0f29c3cb09570e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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