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

Explain the matlab mathematical function library?, This is a huge collectio...

This is a huge collection of computational algorithms ranging from elementary functions like sum, sine, cosine, and difficult arithmetic, to more sophisticated functions like matri

What is the difference among save and save as, Use SAVE when you are revisi...

Use SAVE when you are revising an existing document. Use SAVE AS when you are making a new document from scratch or an existing document. This will remain the original document

Define seek time and latency time, Define seek time and latency time. ...

Define seek time and latency time.  The time taken by the head to move to the appropriate cylinder or track is known as seek time. Once the head is at right track, it must wai

How codes represent data for scientific calculations?, Q. How codes represe...

Q. How codes represent data for scientific calculations? How codes are in fact used to represent data for scientific calculations? The computer is a discrete digital device

Explain assembly language, Explain Assembly Language This is a family o...

Explain Assembly Language This is a family of low-level language for programming computers, microprocessors, microcontrollers etc. They implement a symbolic sign of the numeric

Give difference between assembler and interpreter, Give difference between ...

Give difference between assembler and interpreter. Assembler: It is the translator for an assembly language of computer. An assembly language is a low-level programming langu

How client and server use same protocol port at same time, Can both client ...

Can both client and server use the same protocol port on the same computer at the same time? Explain. Client and server can't use similar port number on similar computer at ide

Execution of micro-program, The micro-instruction cycle can comprises two b...

The micro-instruction cycle can comprises two basic cycles: the fetch and execute. Here in the fetch cycle address of micro-instruction is produced and this micro-instruction is pu

What is random access memory, What is Random access memory (RAM) This i...

What is Random access memory (RAM) This is a volatile memory (i.e. contents are lost when computer is switched off). A user can write or delete data and read the contents. Befo

Where do you set automatic correlation options, Automatic correlation from ...

Automatic correlation from web point of sight can be set in recording options and correlation tab. Here we can enable correlation for the whole script and choose either issue onlin

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