Another opportunity to demonstrate the power of LINQ:
public static decimal MultiplyDecimals(params decimal[] decimals)
{
return decimals.Aggregate(1m, (p, d) => p * d);
}
it
- starts with the initial value
1(the modifier mstatically enters the constant as decimal), and then - iteratively multiplies all values.
EDIT: , . , , ( decimal), :
public static decimal MultiplyDecimals(params decimal[] decimals)
{
return Math.Round(decimals.Aggregate(1m, (p, d) => p * d), 2);
}