度量快速开发平台-专业、快速的软件定制快开平台

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 部件 流程 SQL
查看: 2664|回复: 1
打印 上一主题 下一主题

[分享] 委托

[复制链接]

182

主题

2120

帖子

4842

积分

论坛元老

Rank: 8Rank: 8

积分
4842
跳转到指定楼层
楼主
发表于 2020-3-10 18:41:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1,Delegate的代码

public delegate void myDelegate(string str);
public static void HellowChinese(string strChinese)
{
  Console.WriteLine("Good morning," + strChinese);
  Console.ReadLine();
}

2,Action:指定那些只有输入参数,没有返回值的委托

public static void HellowChinese(string strChinese)
{
  Console.WriteLine("Good morning," + strChinese);
  Console.ReadLine();
}

Action<string> action = HellowChinese;
action("Spring.");

3,Func:有返回值!

public static string HelloEnglish(string strEnglish)
{
  return "Hello." + strEnglish;
}

Func<string, string> f = HelloEnglish;
Console.WriteLine(f("Srping ji"));
Console.ReadLine();

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
沙发
发表于 2020-3-11 18:31:40 | 只看该作者
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|玉祥公司客服-玉祥集团客服  本站关键词:快速开发平台

GMT+8, 2024-5-8 19:08 , Processed in 0.123449 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表