Delegates to Instance Members : Delegate : Delegate C# Examples


C# Examples » Delegate » Delegate »

 

Delegates to Instance Members









    
using  System;

public  class  Machine
{
        string  name;
        public  Machine(string  name)
        {
                this.name  =  name;
        }        
        public  void  Process(string  message)
        {
                Console.WriteLine("{0}:  {1}",  name,  message);
        }
}
class  MainClass
{
        delegate  void  ProcessHandler(string  message);
        
        public  static  void  Main()
        {
                Machine  aMachine  =  new  Machine("computer");
                ProcessHandler  ph  =  new  ProcessHandler(aMachine.Process);
                
                ph("compile");                
        }
}
    
   
  
   



Output

computer: compile


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Delegate
» Delegate