Sum, Min, and Max Methods
So far, we’ve worked with collections of any type. We’ve used a collection of movies, or non-numerals, in our examples. Let’s learn three methods to work with collections of numbers.
How to find the minimum and maximum of a collection
Max methods return the sum, minimum, and maximum of a collection of numbers, respectively. These three methods receive a delegate returning a number as a parameter.
For the following example, let’s change our
Movie class to contain the film duration in minutes. Then let’s find our total watch time, and the shortest and the longest film by duration.