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

Illustrate layout of magnetic disk, Q. Illustrate Layout of Magnetic Disk? ...

Q. Illustrate Layout of Magnetic Disk? Head is a relatively small device capable of reading from or writing to a part of platter rotating beneath it. This gives rise to organiz

Where telephone traffic is measured, Telephone Traffic is measured in ...

Telephone Traffic is measured in (A)  Seconds.  (B)  Hours. (C)  Erlang       (D)  Pulses per minute. Ans: Telephone Traffic is measured in Erlang.

Define object oriented and structured development, How object oriented deve...

How object oriented development is dissimilar from structured development object oriented development is dissimilar from structured development of the system. In the structure

Command mode to insertion mode using vi editor, How to enter from command m...

How to enter from command mode to insertion mode using Vi Editor? Ans) There are various commands that put the VI editor into insert mode. The most usually used commands to get

Dataflow computing, Dataflow Computing A different to the von Neumann m...

Dataflow Computing A different to the von Neumann model of computation is the dataflow computation model. In a dataflow model, control is fixed to the flow of data. The order o

Explain the design reusability of verilog, Explain the Design reusability o...

Explain the Design reusability of Verilog There is no concept of packages in Verilog. Functions and procedures used within a model should be  defined  in  the  module.  To  mak

Project cost, I need help in my M.Sc project ,but im wondering how the cost...

I need help in my M.Sc project ,but im wondering how the cost is calculated

What is a packet switching, End systems are connected together by communica...

End systems are connected together by communication links. There are various types of communication links, which are made of numerous types of physical media, comprising twisted pa

How to select valid lines for secondary list, How to select valid lines for...

How to select valid lines for secondary list? To stop the user from selecting invalid lines, ABAP/4 offers various possibilities.  At the end of the processing block END-OF-SEL

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