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
How cloud can be used in Event Schedules and Management with an example. Web-based calendars can be used to post dates and schedules for specific public events, such as school

Q. Explain the graphic display system? The function of your graphic display system is to display bit-mapped graphics on your monitor.  The image displayed on your system so com

RDBMS relational database system - Relational databases are composed of relations and managed through relational operations, and governed through data integrity constraints.

Ring This is a easy linear array where the end nodes are connected.  It is equivalent to a engage with wrap around connections. The data transmit in a ring is normally one dire

Question: a) What are the reasons for feedback in a control system? b) What are the roles of the configuration and fault managers in a real-time system? c) What are stimu

Building the Structure Chart - Processes in the DFD tend to show single module on the structure chart Afferent processes - give inputs to system Central processes -

The use of distributed shared memory in parallel computer architecture however the use of distributed shared memory has the problem of accessing the remote memory that results in l

The new season of AFL, and the excited coming FIFA World Cup in South Africa this June, many sports fans are willing to find the latest results of their beloved sports teams. In th

Q. Signaling PVM process? int pvm_sendsig( int tid, int signum ) Transmits a signal to other PVM process. tid is task identifier of PVM process to receive signal.

Determine the features of keyboards Common features on general-purpose keyboards are cursor-control keys. Functions keys are used to enter frequently used operations in a singl