c# 自定义事件,实现变量的值改变后就触发该事件


public   delegate   void   delegateHandler();   
  public   class   my   
  {   
        public   int   i=0;   
        public   delegateHandler   myhandle;   
        public   int   changeI   
        {   
                  get{return   i;}   
                  set{   
                          i=value;   
                          myhandle();                           }   
          }   
  }   
    
  public   class   otherclass   
  {   
        public   my   o;   
        public   otherclass()   
  {       o=new   my();   
  }   
  pulic   void   init()   
  {   
        o.myhandle+=new   delegateHandler(howtodeal);   
  }   
  public   void   howtodeal()   
  {   
        //你自己的处理程序   
  }   
          
    
  }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM