tags:

views:

123

answers:

3

Is there any good link for lambda expression (C#) for learn?

If so kindly suggest me one.

In google in searched but may be my luck failed to get any suitable one.

Thanks

+1  A: 

lambda expressions are a general term, and are available in many programming languages, where their semantics are sometimes different.

To put it simply, a lambda expression is usually a function without a name, in languages that allow functions as first-class objects (i.e. pass them around and return them from functions).

Python example:

map(lambda x: x * 2, mylist)

Returns a list with elements that are 2x the elements in mylist (**)

There's also Lambda Calculus, which is more mathematical.

(**) To Python purists: I know list comprehensions are better in this case, I was just trying to show the use of lambda

Eli Bendersky
A: 

Linq is always associated with Lambda Expressions. In .NET 2.0 we have the concept of Anonymous Methods that allows you to write function body inline without the need of writing a delegate function. Lambda Expression of .NET 3.5 is to consize the concept of Annonymous function writing.

Check this out.

Mukesh Rawat
Lambdas go a lot further than anonymous methods can; that only covers half the scenarios, and frankly the less interesting half.
Marc Gravell
Yeh I'm totally agreed with you, but I just want to gave xyz a very simple introduction of that. Coz in two three lines you can't explain the whole concept of Lambda.
Mukesh Rawat
+1  A: 

Lambdas in C# are a two-faced beast. They can operate very much like anonymous methods, or (depending on the method signature) the C# compiler can compile them into Expression trees. The two MSDN links (previous) should help; otherwise books like C# in Depth might light a few bulbs for you. Or I cover expression-trees quite a lot on my blog (or here).

If you are talking about their use in LINQ-to-SQL, Entity Framework, etc - then it is the expression-tree facet that matters; which has a few more limitations than the anonymous-method facet (for example, you can't have a "statement body" in a .NET 3.5 expression-tree - .NET 4.0 trees support this, but the C# 4.0 compiler still doesn't).

Marc Gravell