11.11. Understanding Lambda Expressions
To conclude our look at the .NET event architecture, we will examine C# lambda expressions. As just explained, C# supports the ability to handle events "inline" by assigning a block of code statements directly to an event using anonymous methods, rather than building a stand-alone method to be called by the underlying delegate. Lambda expressions are nothing more than a very concise way to author anonymous methods and ultimately simplify how we work with the .NET delegate type.
To set the stage for our examination of lambda expressions, create a new Console Application named SimpleLambdaExpressions. To begin, consider the FindAll() method of the generic List<T> class. This method can be called when you ...
Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.