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
what is ecs?

Show Library and its types. Libraries constitute a simple meaning of gathering many object files together: 1. Static: during link editing Library code is integrated with t

What is a semaphore? Semaphore: It is a synchronization tool which gives a general-purpose solution to controlling access to critical sections.

Explain about the Public Key Cryptography. Public Key Cryptography: It is a cryptographic system which uses two keys as a public key identified to everyone and a private

Choose one area of rapid technological change in IT or Computer Science and research and report on recent developments and the outlook for the future in the area that you have chos

Explain Hypertext Transfer Protocol. HTTP is used mainly in today's society like a set of rules for exchanging files (graphic images, text, sound, other multimedia files or vid

What are the Advantages of Interviewing - Opportunity to motivate interviewee to give open and free answers to analyst's questions    -  allows analyst to probe for more f

Q. Programmed input - output technique for computers? Programmed input/output is a useful I/O technique for computers where hardware costs need to be minimised. Input or output

Give difference between top down parsing and bottom up parsing. Top down parsing: Specified an input string, top down parsing tries to derive a string identical to this by s

What is a Turing Machine?  Turing machine is a simple mathematical model of a computer. TM has unlimited an unrestricted memory and is a much more accurate model of a general