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
An eight stage ripple counter uses a flip-flop with propagation delay of 75 nanoseconds.  The pulse width of the strobe is 50ns.  The frequency of the input signal which can be use

Accumulator Architecture: An accumulator is anespecially designated register which supplies one instruction operand and receives result. Instructions in such machines are usually

NetDynamics Application Server was the primary Java-based integrated software platform. The product was developed by NetDynamics Inc. As Java became the dominant development langua

Translator for low level programming language were called as    Assembler

Define the component of a process precedence sequence? Ans. Process name, sequence operator and also concurrency operator components are process precedence sequence.

Benefits and benefits of LINQ are: 1. Makes it simpler to transform data into objects. 2. A common syntax for all data. 3. Strongly typed code. 4. Provider integration.

Using               ARQ, a sending modem must wait for a return ACK for each sent block before sending the next block. (A)  discrete                                      (B)

Explain about the Voice recognition system These voice recognition systems recognise spoken words e.g. for disabled people who can't use keyboards where they speak commands rat

Q. Illustrate basic working of Physical layer? Physical layer: Physical layer is concerned with sending raw bits between source and destination nodes over a physical medium.

Various Interconnection Networks Fully connected: This is the most controlling interconnection topology.In this each node is directly linked to all other nodes. The shortcomi