Answer:
public static int display()
{
int[] numbersArray = { 1, 2, 3, 4, 5 };
return numbersArray.Aggregate((x1, x2) => x1 * x2);
}
output : 120
In the above code,
"numbersArray" is an integer array. Here, the first one being the first number or the previous result, and the second one is the second or next number to participate the calculation.
The calculation goes like :-
1 * 1 = 1 (stored in x1)
x1 * 2 = 2 (stored in x1)
x1 * 3 = 6 (stored in x1)
x1 * 4 = 24 (stored in x1)
x1 * 5 = 120 (stored and returned back)
Thanks and Regards
Akiii
Source: MSDN | |
Alert Moderator