Skip to content

Latest commit

 

History

History
42 lines (24 loc) · 1.72 KB

aggregates-4.md

File metadata and controls

42 lines (24 loc) · 1.72 KB

LINQ - Aggregators

Aggregator methods return a single value calculated from all the elements in a sequence. the aggregator methods include Count, Sum, Min, Max, Average, and Aggregate.

Find the average of a sequence of elements

This sample uses Average to get the average of all numbers in an array.

Find the average of a projection

This sample uses Average to get the average length of the words in the array.

Find the average in each group

This sample uses Average to get the average price of each category's products.

Compute an aggregate value from all elements of a sequence

This sample uses Aggregate to create a running product on the array that calculates the total product of all elements.

Compute an aggregate value from a seed value and all elements of a sequence

This sample uses Aggregate to create a running account balance that subtracts each withdrawal from the initial balance of 100, as long as the balance never drops below 0.

Next: Sequence operations » Previous: Aggregates-Min »

Home