A lambda is pretty much just a method without a name. The
(x,y)
part before the => specifies the parameters and the
x * y
part after it is the body of the function.
In this case, what you are doing is the equivalent of:
List<int> lst = new List<int> { 1, 2, 3, 4 };
int x = 0;
for (int i = 0; i < lst.Count; i ++)
{
int y = lst[i];
x = i == 0 ? y : x * y;
}
int result = x;
Only with deferred execution (don't worry about that for the moment).
[edit]Spurious HTML closing tags removed - OriginalGriff[/edit]