Lambda expressions and expression trees
1. introducing the Func<…> delegate types
Here are the signatures
of all the Func delegate types:
public delegate TResult Func
public delegate TResult Func
public delegate TResult Func
public delegate TResult Func
(T1 arg1, T2 arg2, T3 arg3)
public delegate TResult Func
(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Func
delegate int SomeDelegate(string arg1, double arg2)
Func < string > returnHello;
Func < string , string > returnContent;
Func < string , int > returnLength;
returnHello = () => \{ return " Hi David! " ; \};
returnContent = ( string text) => \{ return text; \};
returnLength = ( string text) => \{ return text.Length; \};
Console.WriteLine(returnHello());
Console.WriteLine(returnContent( " Hi David! " ));
Console.WriteLine( " Length of content: " \+ returnLength( " Hi David! " ));
转载于//www.cnblogs.com/davidgu/archive/2011/09/12/2174132.html
还没有评论,来说两句吧...