Monday, April 7, 2008

Lambda Expressions

Lambda Expressions a writing anonymous methods:

IEnumerable <person> results = people.Where(p => p.LastName == "Zeng");

Convent to inline methods:

IEnumerable <Person> results = people.Where( delegate (Person p){return p.LastName = ="Zeng";}
) ;


IEnumerable<Person> advanceResults = people.Where(p => p.LastName == "Zeng")
.OrderBy(p => p.FirstName)
.Take(2);

No comments: