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 the cache memory operation, Q. Illustrate the Cache Memory Opera...

Q. Illustrate the Cache Memory Operation? It comprises a copy of a part of main memory contents. When a program is running and CPU tries to read a word of memory (instruction o

Define the working of flip flops, Define the working of Flip Flops? Fli...

Define the working of Flip Flops? Flip flop is the basic unit of storage this is used to store one bit of information. Flip-flops are the synchronous bistable devices. The term

Neural network programming using matlab, I need the matlab basics for crea...

I need the matlab basics for creating and configuring a neural network with 2 hidden layers

Mathematical model, how to write mathematical model for circular linked lis...

how to write mathematical model for circular linked list

What is meant by the guest function, When  transferring  one  functio...

When  transferring  one  function  to  another,  what  is  meant  by  the  guest  function? A pointer to a function can be passed to another function as an argument. This allows

naming convention in local scope variables, Description Variables show ...

Description Variables show values that can be changed within a procedure or function. Local scope variables are placeholders that reside within a function- or a script-body.

C, "Super ASCII", if it contains the character frequency equal to their asc...

"Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the ascii values will starts from

Determine a program that is in execution, Determine a program that is in ex...

Determine a program that is in execution is known as Program in execution is known as Process

Add multiple layout cells, Q. Add Multiple Layout Cells ? Next you will...

Q. Add Multiple Layout Cells ? Next you will add three layout cells below the logo cell you just created. Afterwards you will insert page's navigation buttons in these cells.

Observations of high level language program, Q. Observations of High Level ...

Q. Observations of High Level Language Program? Observations Integer constants appeared nearly as frequently as structures or arrays. Most of the scalars were foun

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