Lambda's advanced query

When using delegates, there are so few steps:

1, define delegates

2, delegate instantiation

3, the method of adding the pointer to the object delegate instantiation

Lambda expressions, is a simplified anonymous function

 

effect:

1, can be used to create a delegate or an expression tree

2, may be passed as a parameter Lambda expressions

3, it acts on the value returned after the call function using a

Basic form:

(Input parameters) => expression

 

Lambda expressions are entrusted implementation, must comply with the following rules:

1, the same Lambda expressions and the number of parameters number of parameters delegate

2, if the delegate modifier comprises ref or out, the parameters are listed Lambda expressions modifiers must also include

3, if there is a return type delegate, the statement or expression Lambda statement blocks must return the same type of data

4, if the commission there are several types of data formats and the compiler can not infer the specific type of data in Lambda expressions, the

You must manually define data types

 

In using the Linq Lambda:

Many parameters LINQ delegate type is a kind of parameters, such as Func <T, TResult>, you can define input parameters and return types.

public delegate TResult Func<TArg0, TResult>(TArg0 arg0) 

Func <int, bool> represents: int input parameters, bool return value.

Func <int, int, bool> represents: int two input parameters, return to a bool value.

 

Guess you like

Origin www.cnblogs.com/lxlxlx/p/11203271.html