What is a lambda expression, Computer Engineering

Assignment Help:

 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.

 

 


Related Discussions:- What is a lambda expression

Avoiding local minima, Avoiding Local Minima: However the error rate o...

Avoiding Local Minima: However the error rate of multi-layered networks over a training set could be calculated as the number of mis-classified examples. So always keep in rem

Corrosion, Explain the mechanidm of the rusting of iron on the basis of ele...

Explain the mechanidm of the rusting of iron on the basis of electrochemical corrosion?

What are the features of prom, What are the features of PROM? They are ...

What are the features of PROM? They are programmed directly by the user. Faster Less expensive More Flexible

What are batch systems, What are batch systems?  Batch systems are quit...

What are batch systems?  Batch systems are quite appropriate for implementing large jobs that need little interaction. The user can submit jobs and return later for the results

What is hysteresis, What is hysteresis? Hysteresis is well known in fer...

What is hysteresis? Hysteresis is well known in ferromagnetic materials. When an external magnetic field is applied to a Ferro magnet, the atomic dipoles align themselves with

What happens if acknowledge() is called within a transaction, As per the JM...

As per the JMS specification, when you are in a transaction, the acknowledge Mode is ignored. If acknowledge() is known as within a transaction, it is ignored.

Give brief explanation about the keyboards, Give brief explanation about th...

Give brief explanation about the keyboards Keyboards are generally not offered as the number of options is limited and owners of the system do not want customers keying in info

Mobile computing, Explain the key characteristics of mobile computing appli...

Explain the key characteristics of mobile computing applications

State the advantages off-the-shelf, State the advantages Off-the-shelf ...

State the advantages Off-the-shelf -  tends to be less expensive as development costs can be spread over many users -  can be more sophisticated as large sales bring in c

Network, Give an intuitive explanation of why the maximum throughput, for s...

Give an intuitive explanation of why the maximum throughput, for small beta, is approximately the same for CSMA slotted Aloha and FCFS splitting with CSMA. Show the optimal expecte

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd