using System;
public class Program
{
//1. 'params' keyword allows us to pass a variable number of values into a method
//2. Doing this means a single method is more flexible
public static double FindSum(params double[] values)
double sum = 0; //3. Be sure to start with 0 so the sum will not be thrown off
foreach (var d in values)
sum += d; //4. sum +=d adds up the values in the array as the loop runs
return sum; //5. Send total value or sum back to the body of Main
}
public static void Main()
Console.WriteLine("1+2={0}", FindSum(1, 2)); //6. Calls FindSum with 1,2
Console.WriteLine("4+5+10={0}", FindSum(4, 5, 10)); //7. Now FindSum works with 4,5 and 10