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
Generally the register storage is faster than cache andmain memory. Also register addressing uses much shorter addresses than addresses for cache and main memory. Though the number

super string checker

What is virtual memory?  Virtual memory is a technique that permits the execution of processes that may not be completely in memory. It is the separation of user logical memory

Explain the Fixed Logic Versus Programmable Logic? The Logic devices can be classified into two broad categories - fixed and programmable. The same as the name suggests, the ci

An expert system also represents knowledge symbolically as sets of symbols that stand for problem concepts. In AI jargon symbol is a string of characters that stands for

What is imprecise and precise exception? Situation in which one or more of the succeeding instructions have been implemented to completion is known as imprecise exception. Situ

What is the chief advantage of using virtual packets instead of frames? The router can't transfer a copy of a frame from one kind of network to another since the frame formats

What is Arithmetic and Logic Unit Arithmetic and Logic Unit: The ALU is the 'core' of any processor. It implements all arithmetic operations (addition, multiplication, subtract

Clarify the operation of IRET instruction.  What memory locations comprise the vector for an INT 34 instruction? Interrupt return (IRET) instruction is used only with hardware

There are three primary colours in pigments - Red, Yellow and Blue. There are two ways to produce more colours:   Physical Mixing: Physically mix colours to produce a new colour