1.expression<func<t,tresult>> is an expression
Use LambdaExpression to build an expression tree expression<func<int, int, int, int>> expr = (x, y, z) = = (x + y)/z; Console.WriteLine (Expr.compile () (1, 2, 3));
Https://msdn.microsoft.com/zh-cn/library/system.linq.expressions.expression (v=vs.100). aspx
https://msdn.microsoft.com/zh-cn/library/bb335710 (v=vs.100). aspx
2.func<t, Tresult> commissioned
Encapsulates a method that has a parameter and returns the type value specified by the TResult parameter.
Public delegate TResult Func<in T, out tresult> (t Arg)
Type parameter
In T
The parameter type of the method encapsulated by this delegate.
The type parameter is contravariant. That is, you can use a specified type or a lower-derived type. For more information about covariance and contravariance, see Covariance and contravariance in generics.
Out TResult
The return value type of the method encapsulated by this delegate.
The type parameter is covariant. That is, you can use the specified type or a higher-derived type. For more information about covariance and contravariance, see Covariance and contravariance in generics.
Parameters
Arg
Type: T
The parameters of the method encapsulated by this delegate.
return value
Type: TResult
The return value of the method encapsulated by this delegate.
String mid = ", middle part,"; Anonymous notation func<string, string> Anondel = delegate (string param) {param + = mid; param + = "and this is added to the string."; return param; }; λ expression func<string, string> lambda = param = {param + = mid; param + = "and this is added to the string."; return param; }; λ expression (shaping) func<int, int> lambdaint = Paramint + = {Paramint = 5; return paramint; }; Lambda expression with two arguments func<int, int, int> twoparams = (x, y) + = {return x *y; }; MessageBox.Show ("anonymous method:" +anondel ("Start of String")); MessageBox.Show ("Lambda expressions:" + lambda ("lambda expression")); MessageBox.Show ("λ-expression (shaping):" + lambdaint (4). ToString ()); MessageBox.Show ("lambda expression with two parameters:" + twoparams (10, 20). ToString ());
Expression<func<t,tresult>> and Func<t,tresult>