The first thing that we're going to do is create a function or method that will allow us to summarize an array. Create a new line under the class Program opening curly brace and type the following:
static void Summarize(double[] values, out double sum, out double average) { }
So, our function will accept an array of doubles, which we'll call values. We then have a couple of variables for sum and average. Note that both of these use the out keyword.
Next, within the curly braces of our Summarize function, type the following:
sum = average = 0;
This will simply set our two values to 0. Next, we are going to form the sum. For this, type the following:
foreach(var d in values)
So here we are telling the program to go in and grab each value in the values array using foreach, then we are going to perform an action on that value. In this...