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