top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What are Lambda Expressions?

+6 votes
What are Lambda Expressions?
posted Feb 13, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Lambda Expressions are nameless functions given as constant values, and written exactly in the place where it's needed, typically as a parameter to some other function. The canonical example is that you'll pass a comparison function to a generic "sort" routine, and instead of going to the trouble of defining a whole function (and incurring the lexical discontinuity and namespace polution) to describe this comparison, you can just pass a lambda expression describing the comparison.

HOWEVER, this misses one of the most important features of Lambda Expressions, which is that they execute in the context of their appearance. Therefore, they can use the values of the variables that are defined in that context.

Lambda expressions appear (with different syntax) in all LISPs, Perl, Python, and many other languages, but notably not C, Java, or any similar language, even though those all have a way to deal with passing functions (or some excuse for them) around as parameters. They are a syntax element with particular semantics, and those semantics place more requirements on the runtime than C was designed to require.

Check the following link for lambda exp in C#

answer Feb 13, 2014 by Meenal Mishra
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.