zoukankan      html  css  js  c++  java
  • 委托——不同写法

    namespace 委托练一练
    {   
        //public delegate void Weituo(string x,int i);//定义委托
        //public delegate void Niming(int z);//定义一个委托(用来匿名的)
        //public delegate int Fanhui(int z);//带返回值的
        public delegate int Goes(int i, int j); //lambda表达式
     
    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //Weituo x = new Weituo(Show);
                //x("吗",1);
                //Niming y = new Niming(delegate(int z) { textBox1.Text = "匿名委托"+z; });//匿名委托
                //y(3);
                //Fanhui f = new Fanhui(delegate(int z) { textBox1.Text = "你好"+z; return z; });//带返回值的
                //f(2);
                Goes g = (int i, int j) => { textBox1.Text = "你好"+(i + j).ToString(); return i + j; };
                g(100, 200); //lambda表达式
     
    } public void Show(string x,int i) { textBox1.Text = "你好"+x+i.ToString(); } } }
  • 相关阅读:
    week4
    week3
    2017福州大学面向对象程序设计寒假作业二
    Week2
    10个android开发必备的开源项目
    Day Ten
    Day Nine
    Day Eight
    Day Seven
    Day Six
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4621139.html
Copyright © 2011-2022 走看看