This would work:
var product = vals.Aggregate(1, (acc, val) => acc * val);
You're starting with a seed of 1
and then the function is called for each of your values with two arguments, acc
which is the current accumulated value, and val
which is the value in the array; the function multiplies the current accumulated value by the value in the array and the result of that expression is passed as acc
to the next function. i.e. the chain of function calls with the array you provided will be:
(1, 1) => 1
(1, 3) => 3
(3, 5) => 15