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

Advantages and drawbacks of mealy and moore machine, What are the advantage...

What are the advantages and drawbacks of mealy and moore machine? Advantages and drawbacks: Into Mealy as the output variable is a function both state and input, changes o

State the disadvantages of interviewing, State the Disadvantages of  inter...

State the Disadvantages of  interviewing -  can be expensive to carry out    -  can be a very time consuming exercise -  Unable to remain anonymous

What is a data class, What is a Data Class? The Data class verifies in ...

What is a Data Class? The Data class verifies in which table space the table is stored when it is formed in the database

Translator for low level programming language, Translator for low level pro...

Translator for low level programming language were called as    Assembler

Explain program source code, Q. Explain Program Source Code? Program S...

Q. Explain Program Source Code? Program Source Code  Every assembly language statement appears as: {identifier}  Keyword {{parameter},}  {;comment}.   Element of a

Name the two operations of stack, Name the two operations of stack A st...

Name the two operations of stack A stack has only two operations and they are insertion and deletion of items. The operation insertion is called push (or push-down) as it can b

Explain functions introduction, Common used functions are placed within lib...

Common used functions are placed within libraries in the SQABasic directory. Files ending with ".SBH" have the public interface they give to other libraries and scripts. Files endi

Handling interrupts - computer architecture, Handling Interrupts: Pre...

Handling Interrupts: Precise interrupts (sequential semantics) Complete instructions before the offending instructions o   Force trap instruction into IF o

what is polymorphism in c++, Polymorphism in C++ is the idea that a base c...

Polymorphism in C++ is the idea that a base class can be inherited by various classes. A base class pointer can point to its child class and a base class array can store dissimilar

Assignment, zero, one, two three address instructions

zero, one, two three address instructions

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