System.Action委托
类别:编程学习 浏览量:86
时间:2016-7-27 System.Action委托
System.Action委托一、传统的委托定义及调用
using System;
using System.Windows.Forms;
public delegate void DisplayMessage();
public class testTestDelegate
{
public static void Main()
{
DisplayMessage showMethod = DisplayToWindow();
showMethod();
}
public static void DisplayToWindow()
{
MessageBox.Show("http://www.studyofnet.com");
}
}
二、System.Action实现委托
using System;
using System.Windows.Forms;
public class testTestDelegate
{
public static void Main()
{
Action showMethod = DisplayToWindow;
showMethod();
}
public static void DisplayToWindow()
{
MessageBox.Show("http://www.studyofnet.com");
}
}
三、使用Lambda的方式调用System.Action实现委托
using System;
using System.Windows.Forms;
public class testTestDelegate
{
public static void Main()
{
Action showMethod = () =>{ MessageBox.Show("http://www.studyofnet.com"); };
showMethod();
}
}
标签:委托
热门推荐
- 微信小程序单选框组件(微信小程序picker多列选择器mode = multiSelector)
- VS中生成与重新生成的区别
- 服务器之家浅谈VPS和云主机的区别(服务器之家浅谈VPS和云主机的区别)
- css五种使用方法(CSS 的加载及加载顺序简介)
- 数据库sql位置更换磁盘(SQL SERVER迁移之更换磁盘文件夹的完整步骤)
- mysql5.7.19下载及安装教程(Apache2.2.16+PHP5.3.3+MySQL5.1.49的配置方法)
- python爬虫音乐代码(详解python selenium 爬取网易云音乐歌单名)
- python 文件操作(Python File文件 方法整理)
- python自动处理图片(python制作图片缩略图)
- python 队列与列表(Python实现的栈、队列、文件目录遍历操作示例)