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
Question: (a) Describe the differences between a URI, a URN and a URL. (b) What are the five basic syntax rules for a well-formed XML document? (c) Provide four uses of

Distortion caused on telephone line by an adjacent one is called (A) Cross Fire                      (B) Inductive Disturbance (C)  Cross Talk                     (D) Non

What is store program control (SPC)?  In  stored  program  control  systems,  a  set  of  instructions  or  program  to  the computer  is  stored  in  its  memory  and  instru


Question 1 What is modulation? Explain why is modulation required? 2 Briefly explain about ASK, FSK and PSK 3 Explain about the Nyquist Bandwidth and Nyquist Theorem 4

Converter is an application that converts distance measurements among metric and U.S units.

What is divide overflow?  The division operation might result in a quotient with an overflow. Overflow happens when the length of the registers is finite and will not hold a nu

Question: (a) Explain clearly the difference between a Proposal and a Treatment for a video production project. (b) Explain clearly the difference between Narrative form an

Explain the term Electronic Data Interchange (EDI). Electronic Data Interchange (EDI) may be generally easy to understand as the replacement of paper-based purchase orders alon

SS7 Protocol uses: (A) Out of band signalling. (B) Associated signalling. (C) Speech control signalling. (D) No signalling. Ans: SS7 Protocol uses Out of