zoukankan      html  css  js  c++  java
  • paip.c#使用匿名函数建立委托提高可读性



    paip.c#使用匿名函数建立委托提高可读性


    作者Attilax ,  EMAIL:1466519819@qq.com


    使用普通方法建立委托,太麻烦,影响可读性。。使用匿名函数是个好方法,大大提升了可读性.






    1.函数与委托定义在一个文件内
    ------------------


        delegate void clsC417();


     xxx()
    {


                    //setStatubarCount  c4g


                    clsC417 clsobj = new clsC417(
                     delegate
                     {
                         toolStripStatusLabel3.Text = "/" + ct.loadRecNum;


                     });
                    clsobj();
                    //end c4g




    }












    2.函数与委托定义不在一个文件的
    ----------------------


                m.timex tx = new timex();
                tx.start(delegate(string time) {


                    toolStripStatusLabel4.Text = "运行时间:"+time;
                
                });










    -----timx.cs-------------


     public  delegate void callback(string time);
      public  class timex
    {




       public void start(callback cbk)
          {
      cbk("dddd");
    }






    }
  • 相关阅读:
    交换实验
    ISIS简单配置
    bgp联盟
    BGP2
    BGP 1
    BGP反射器
    ospf实验3
    bzoj 4503: 两个串
    bzoj 4259: 残缺的字符串
    COGS 2287. [HZOI 2015]疯狂的机器人
  • 原文地址:https://www.cnblogs.com/attilax/p/15199676.html
Copyright © 2011-2022 走看看