Here's another great link showing lambda operator.
One thing that still amazes me is how people react to the trend we are observing. Some of the people I show this link rather use:
int val = Fold(
delegate(int a, int b) { return a * b; },
1, 3, 5, 7, 9
);
delegate(int a, int b) { return a * b; },
1, 3, 5, 7, 9
);
over:
int val = Fold((a, b) => a * b, 1, 3, 5, 7, 9);
Go figure...
Here's another sample from the same post (I've corrected the typo error as no integer squares to 5).
Listlist = new List {
1,
2,
3,
4,
5
};
Listmatches =
list.FindAll(
val => {
val = val * val;
return val != 9;
}
);
The resulting list should return {1, 2, 4, 5}.
No comments:
Post a Comment