由winform来看action与delegate的区别
2020-12-12 20:56
标签:winform style blog class code c 在第一个窗口添加一个按钮并添加点击监听 很明显了,使用lambda+系统委托更优美 由winform来看action与delegate的区别,搜素材,soscw.com 由winform来看action与delegate的区别 标签:winform style blog class code c 原文地址:http://www.cnblogs.com/hualongbei/p/3730832.html 1 private void button1_Click(object sender, EventArgs e)
2 {
3 Form2 f = new Form2();
4 //第一点:简洁
5 //action and lambda
6 f.alEmethod += (s => this.textBox1.Text = s);
7 //delegate and method
8 f.dmEmethod += delegate(String s){this.textBox1.Text = s;};
9 f.ShowDialog();
10 }
1 public partial class Form2 : Form
2 {
3 //第二点:复杂,冗余
4 //使用Action和Lamdba
5 public event Action
文章标题:由winform来看action与delegate的区别
文章链接:http://soscw.com/index.php/essay/23646.html