What is a lambda expression, Computer Engineering

 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.

 

 

Posted Date: 4/3/2013 2:04:37 AM | Location : United States







Related Discussions:- What is a lambda expression, Assignment Help, Ask Question on What is a lambda expression, Get Answer, Expert's Help, What is a lambda expression Discussions

Write discussion on What is a lambda expression
Your posts are moderated
Related Questions
Unions allow the same area of memory to be accessed as different data types. The insurance example above would not work. Unions are useful (often in embedded programming) when i

Reprography In order to disseminate information widely some method of reprography is invariably used. Reprography is the science and practice of copying documents by photograph

Over fitting Considerations : Hence in left unchecked there backpropagation in multi-layer networks can be highly susceptible to overfitting itself to the training examples. B

Task A logically discrete sector of a computational effort. A task is naturally a program or program-like set of instructions that is implemented by a processor.  Parallel

Illustrate about the Word processors with its design Word processors now have many aspects over and above the original task of generating a typed document. This section would

Q. How to define a Filename in DOS? Each file is given a name so that it can be referred to later. This name is termed as Filename. The filename in DOS can be up to eight alpha

Internal Path length It is described as the number of node traversed while moving by one particular node to any other node in the tree.

The customers visit the website and browse through the products, looking at pictures and products details. When the customer finds his desired product, he usually adds it to his ca

Hyper-threading works by duplicating those sections of processor that kept the architectural state-but not duplicates the main implementation resources. This allows a Hyper-threadi

At a particular moment in time the output of a COMBINATIONAL logic circuit depends uponthe inputs to the circuit at the same instant.(Unlike sequential logic circuits where the out