From the course: .NET Essentials: Working with LINQ

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Sum, Average, and other aggregates

Sum, Average, and other aggregates - .NET Tutorial

From the course: .NET Essentials: Working with LINQ

Sum, Average, and other aggregates

- [Instructor] What we're looking at in this chapter are the aggregate functions, and all aggregate functions work in a similar fashion. Here's an example at the top of this editor. So an aggregate starts with a sequence. In this case it's A, B, C, D, and E. You define some sort of operation and then that operation is applied to each successive pair. We'll start with the operation on AB and then some other values. I've listed those here. The first operation is AB and that gives you a result. Let's say it's adding those two numbers together. So the total of A and B will be listed here. Then it goes to the next item in the list, B and the result. So it performs the addition on that and then C and the result, D and the result, and E and the result. That's the classic example of building a sum function. You're totaling all the items in the list. Microsoft has created that function for us. Here it is, it's called sum.…

Contents