Lambda expressions and expression trees

柔光的暖阳◎ 2021-12-24 12:43 284阅读 0赞

1. introducing the Func<…> delegate types

Here are the signatures
of all the Func delegate types:
public delegate TResult Func()
public delegate TResult Func(T arg)
public delegate TResult Func(T1 arg1, T2 arg2)
public delegate TResult Func
(T1 arg1, T2 arg2, T3 arg3)
public delegate TResult Func
(T1 arg1, T2 arg2, T3 arg3, T4 arg4)

Func is equivalent to a delegate type of the form
delegate int SomeDelegate(string arg1, double arg2)


Func < string > returnHello;
Func < string , string > returnContent;
Func < string , int > returnLength;

  1. returnHello = () => \{ return " Hi David! " ; \};
  2. returnContent = ( string text) => \{ return text; \};
  3. returnLength = ( string text) => \{ return text.Length; \};
  4. Console.WriteLine(returnHello());
  5. Console.WriteLine(returnContent( " Hi David! " ));
  6. Console.WriteLine( " Length of content: " \+ returnLength( " Hi David! " ));

转载于:https://www.cnblogs.com/davidgu/archive/2011/09/12/2174132.html

发表评论

表情:
评论列表 (有 0 条评论,284人围观)

还没有评论,来说两句吧...

相关阅读

    相关 express

    概述 Express 是基于 node.js 平台的一个简洁而灵活的应用程序开发框架;express 为 Web 和移动应用程序提供了一系列强大功能和丰富的 HTTP 实