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

What are the concerns for growth of e-commerce in india, What are the conce...

What are the concerns for growth of e-commerce in India? Government as Facilitator for the growth of e-commerce has taken following steps: a. Promotion of competitive dataco

Digital electronics, what is Asynchronous Finite State Machines?

what is Asynchronous Finite State Machines?

Performance of caches - computer architecture, Performance of caches: ...

Performance of caches:       Amdahl's Law regarding overall speed up:                  Alternatively, CPU stall can be considered:

Give an account of issue pertaining in c language, Give an account of the i...

Give an account of the issue pertaining to compilation of if statement in C language Control structures as if cause significant gap in between the PL domain and the execution d

Show block diagram of sequential circuits, Q. Show block Diagram of sequent...

Q. Show block Diagram of sequential circuits? A sequential circuit is an interconnection of storage elements and combinational circuits. The storage elements known as flip-flop

Find the boolean expression for boolean algebra, Find the Boolean expressio...

Find the Boolean expression for logic circuit shown in Figure below and reduce it using Boolean algebra. Ans. Y = (AB)' + (A' + B)' = A' + B' + AB' by using Demorgan's Theorem. =

What are the type of internet connection, What are the type of Internet con...

What are the type of Internet connection When determining requirements for a VPN, carefully estimate the number of systems to be put behind the VPN, the number of concurrent u

What is status control and registers, Q. What is Status Control and Registe...

Q. What is Status Control and Registers? Status Control and Registers: These registers can't be used by programmers though are used to control CPU or execution of a program.

Differentiate between intranet and internet, Differentiate between intranet...

Differentiate between intranet and internet Some comparisons between intranet and internet include: -  INTERNET is INTERnational NETwork -  An INTRANET is INTernal Restri

Why do we need registers, Why do we need Registers? If t cpu is cycle...

Why do we need Registers? If t cpu is cycle time of CPU which is the time taken by CPU to execute a well-defined micro-operation employing registers and t mem is memory cycl

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