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
Define formal language grammar? A formal language grammar is a set of formation rules which describe that strings made by the alphabet of a formal language are syntactically va

With reference to telephone traffic, explain the terms GOS. GOS: in loss systems, the traffic carried through the network is usually lower than the actual traffic offered to

Explain about the term E-Cash. E-cash is cash demonstrated by two models. E-cash has one is on-line form of e-cash, that is introduced by DigiCash that permits for the completi

RAM parity checking is the storing of a redundant parity bit showing the parity odd or even of a small amount of computer data typically one byte stored in random access memory, an

Q. What is Small Computer Systems Interface? The other well-liked way is to connect a disk drive to a PC by a SCSI interface. Common drive choice for high-end workstations or s

Explain the Modularity of Object oriented analysis Modularity is closely attached to encapsulation; you may think of it as a way of mapping encapsulated abstractions into phys

a. Design a fast adder. What are the variations in a fast adder? b. Define how the virtual address is changed into real address in a paged virtual memory system. Give an example

The Signalling connection control part (SCCP) and message transfer part (MTP) together are referred to as (A) Signal Switching Points (SSPs) (B)  Signal Transfer Points

Incidence Matrix: - This is the incidence matrix for an undirected group. For directed graphs, the vertex from where an edge is originating will have +1 and the vertex where the ed

Describe Real and protected mode: Operation of Real mode interrupt:   When microprocessor completes executing the current instruction, it concludes whether an interrupt is act