Help
Delegates and the Lambda Expression Print E-mail
Written by Carlton Colter   
Tuesday, 26 May 2009 13:28

Delegates

Akadia's article on Delegates and Events in C# / .NET easily explains the basic concept of a delegate. A delegate only cares about the return type and parameters passed. Delegates are extremely useful when building dynamic systems capable of handling multiple types and processing them differently based on a few pieces of information.

Delegates don't have to be predefined functions. In .net 2.0 you could sort a list of books using:

Lamda Expressions

I found the article Lambda Expressions on Eric White's blog extremely helpful in understanding the concept and styling method, but it lacks some real world uses and examples.

Sorting and filtering are some of the most useful ways to use lambda expressions. A good filter example can be found on Sam Page's blog.

Lamda expressions simplify the delegate definition, allowing quick and easy delegates. Below is how to sort the same list using .net 3.0

Lambda's provide an easier way to call a delegate, and simplify your code.

Last Updated ( Tuesday, 26 May 2009 14:03 )