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

Interconnection network in the form of a linear array, Q. Interconnection n...

Q. Interconnection network in the form of a Linear Array? The sorting problem particularly selected is bubble sort and interconnection network may be represented as n processor

Explain the concept of overriding, What is overriding? Overriding is an...

What is overriding? Overriding is an inherent part of association. It can show an ordered set of objects by writing {ordered} next to the appropriate association end. In 200

Explain vehicle tracking system, Case Study - A taxi company has 200 taxies...

Case Study - A taxi company has 200 taxies. The company provides its services to all the nine districts in Mauritius, about 20 taxies per district. A taxi is normally attached to

Gather some ram data after system was powered off, (a) When a forensic exa...

(a) When a forensic examiner arrives at a crime scene, the first task done is referred to as "Incident Response". Summarize the different incident response tasks done in 10 steps.

Find the complement of following functions, Q. Find the complement of follo...

Q. Find the complement of following functions and reduce to minimum literals 1. (A+C+D) (A+C+D') (A+C'+D)(A+D') 2. ABC(ABC' + AB'C + A'BC) 3. AB + AB' + A'C +A'C'

How can we draw a circle with gimp, Ans) The simplest way is to make a new ...

Ans) The simplest way is to make a new selection with Ellipse Select tool and stroke it (Edit -> Stroke Selection...). We welcome patches that add tools to draw geometric primitive

Mapping, what is transform mapping and transaction mapping?

what is transform mapping and transaction mapping?

What is roll area, What is roll area? A roll area having the program's...

What is roll area? A roll area having the program's runtime context.  In addition to the runtime stack and other structures, all local variables and any data known to the prog

Add a byte number from one memory location, Add a byte number from one memo...

Add a byte number from one memory location to a byte from subsequent memory location and put sum in the third memory location. Also save carry flag in the least significant bit of

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