What is a lambda expression, Computer Engineering

 A Lambda expression is not anything but an Anonymous Function, can have expressions and statements. Lambda expressions can be used mostly to make delegates or expression tree types. Lambda expression uses lambda operator => and read as 'goes to' operator.

 

Left side of this operator specifies the input parameters and haves the expression or statement block at the right side.

 

Example: myExp = myExp/10;

 

Now, let see how we can assign the above to a delegate and make an expression tree:

 

delegate int myDel(int intMyNum);

static void Main(string[] args)

{

//assign lambda expression to a delegate:

myDel myDelegate = myExp => myExp / 10;

int intRes = myDelegate(110);

Console.WriteLine("Output {0}", intRes);

Console.ReadLine();

 

//Create an expression tree type

//This needs System.Linq.Expressions

Expression myExpDel = myExp => myExp /10;

}

 

Note:

The => operator has the similar precedence as assignment (=) and is right-associative.

 

Lambdas are used in method-based LINQ queries as arguments to standard query operator methods such as Where.

 

 

Posted Date: 4/3/2013 2:04:37 AM | Location : United States







Related Discussions:- What is a lambda expression, Assignment Help, Ask Question on What is a lambda expression, Get Answer, Expert's Help, What is a lambda expression Discussions

Write discussion on What is a lambda expression
Your posts are moderated
Related Questions
In the message-passing model, there exists a set of tasks that use their own local memories during computation. Multiple tasks can reside on the similar physical machine as well ac

Given memory partitions of 100k, 500k, 200k, 300k, and 600k (in order), apply first fit and best fit algorithms to place processes with the space requirement of 212k, 417k, 112k an

WestEast College hires you as a systems analyst to design its new admission/registration system. WestEast College is one of the top ranked schools in the United States. It is a

In order to support IA-32 Itanium can switch in 32-bit mode with special jump escape instructions. IA-32 instructions have been mapped to Itanium's functional units. But as Itanium


types of lock

Question : Multimedia involves multiple modalities of text, audio, images, drawings, animation, and video (a) Describe three popular file formats for images (b) Most imag

What is the Main difference between ASP and ASP.NET ?   ASP contains scripts which are not compiled while in ASP.net the code is compiled.

When the user is inputting commands into your shell, it should properly handle delete and backspace. When one of these characters is detected, you will need to remove one character