Thursday, June 19, 2008

C# Lambda Expressions Can Contain Method Bodies

I know a lot of people who love and use the lambda expression syntax provided in C# 3.0 as a shortcut for explicit delegate definitions.

Suprisingly however, quite few of them actually know that lambda expression can not only have a suprisingly variable => expression form like:

x => x < 5

but can also contain method bodies as expressions like



x => { Console.WriteLine( x ); return x < 5; }

No comments: