O'Reilly logo

WCF 4.0 Multi-tier Services Development with LINQ to Entities by Mike Liu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lambda expressions

With the C# 3.0 new feature extension method and the C# 2.0 new feature anonymous method (or inline method), Visual Studio introduces a new expression called lambda expression.

Lambda expression is actually a syntax change for anonymous methods. It is just a new way of writing anonymous methods. Next, let's explain what a lambda expression is, step by step.

First, in C# 3.0, there is a new generic delegate type, Func<A,R>, which presents a function taking an argument of type A and returns a value of type R:

delegate R Func<A,R> (A Arg);

In fact there are several overloaded versions of Func of which Func<A,R> is one.

Now we will use this new generic delegate type to define an extension:

public static IEnumerable<T> Get<T>(this IEnumerable<T> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required