其实他们两个都是委托【代理】的简写形式。

一、【action<>】指定那些只有输入参数,没有返回值的委托

Delegate的代码:

  1. public delegate void myDelegate(string str);
  2. public static void HellowChinese(string strChinese)
  3. {
  4. Console.WriteLine("Good morning," + strChinese);
  5. Console.ReadLine();
  6. }
  7. myDelegate d = new myDelegate(HellowChinese);
  8. d("Mr wang");

用了Action之后呢:

  1. public static void HellowChinese(string strChinese)
  2. {
  3. Console.WriteLine("Good morning," + strChinese);
  4. Console.ReadLine();
  5. }
  6. Action<string> action = HellowChinese;
  7. action("Spring.");

就是相当于省去了定义委托的步骤了。

二、func<> 这个和上面的那个是一样的,区别是这个有返回值!

    1. public static string HelloEnglish(string strEnglish)
    2. {
    3. return "Hello." + strEnglish;

最新文章

  1. MongoDB系列一:CentOS7.2下安装mongoDB3.2.8
  2. fetch 资源请求
  3. install docker on xubuntu
  4. C# TreeView的CheckBox 父/子节点点击联动选择效果
  5. IE8/9的console之坑
  6. JAVA基础知识之多线程——线程同步
  7. fushioncharts的使用教程
  8. ctags 文章
  9. python内建函数sorted方法概述
  10. httpClient模拟浏览器发请求
  11. Java项目中基于Hibernate分页总结
  12. uva-10487 - Closest Sums
  13. 《转载》CSS中的三种样式来源:创作人员、读者和用户代理
  14. 【动态规划】【归并】Vijos P1412 多人背包
  15. Scala学习笔记--xml
  16. 重写ViewPager实施单一交有关切换到这个问题,并没有缓存
  17. Appium键盘操作
  18. A标签中通过href和onclick传递的this对象
  19. Python教程(2.1)——控制台输入
  20. ConcurrentHashMap基于JDK1.8源码剖析

热门文章

  1. 关于直播学习笔记-004-nginx-rtmp、srs、vlc、obs
  2. 处理unsigned相减错误(BIGINT UNSIGNED value is out of range)
  3. 常用hive的CLI命令
  4. linux--GCC用法
  5. vertical-align负值和margin-bottom负值的区别
  6. PHP创建文件以及移动文件
  7. 关于Java中按值传递和按引用传递的问题详解
  8. luogu P2066 机器分配[背包dp+方案输出]
  9. luogu P1379 八数码难题(A*算法入门详细讲解)
  10. python随机验证码函数