Lambda Expressions via

A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types. All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x."

> more

Overview of Lambda Expressions

One of the new .NET 3.x language features that we have been enjoying recently is Lambda Expressions. These expressions are essentially the next iteration of the anonymous methods that were offered with .NET 2.0, with one of the major differences being the simplicity with which you can construct inline methods. When used appropriately, these Lambda Expressions let us get more done with less code and less redundancy.

Lambda Expressions In Practice

Let's say you run into a situation in which you want to write a method that takes as an argument an object of a particular type and a property on the object you want to work with. For example if we take the example below and want to make the redundant parts (in blue text) a shared method, except the different property (in red text) being used is potentially holding us up. (Continue reading for example code).

Results Per Page 
Page: 1 2 



Powered by Twitter