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
Discuss the use of Artificial intelligence techniques in E-Commerce applications. Explain about the various uses of Artificial Intelligence in Medicine field. Justify it with pr

How are problems of clock skew minimized? Clock skew, when done right, can also benefit a circuit. This can be intentionally introduced to reduce the clock period, at that the

Resolution Method: For a minor miracle occurred in 1965 where Alan Robinson published his resolution method as uses a method to generalised version of the resolution rule of i

Discuss the mount and unmount system calls. The privileged mount system call is used to join a file system to a directory of another file system; the unmount system call detach

Bit Serial Associative Processor (BSAP) : When the associative processor accepts bit serial memory organization then it is known as bit serial associative processor. While only one

Q. (192.8)10 - (AE.E)16 = (X)8, Find value of x. Use 8's complement method. Q. Write first 10 numbers in the base 4. Q. Explain Error-Detection code & Error-correction code w

In order to concatenate strings only for output purposes which command can be used in conjunction with the 'Write' statement. NO-GAP command.

What are the techniques of Data Collection It can be either automatic or manual. Manual techniques can include: -  Keypads/Keyboards to type in data -  touch screens to s

Assignment:  write a C program and a MASM procedure.  The C program calls the MASM procedure to perform letter case conversion. Text sections covered:  12.1 to 12.3.1 Write a

Explain in detail about Touch screens For people who can't use a keyboard allowing input; also helps people with learning difficulties since icons are easier to understand