Late Binding Delegates : delegate : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » delegate »

 

Late Binding Delegates








    
 

using System;
using System.Reflection;

delegate void XDelegate(int arga, int argb);

class MyClass {
    public void MethodA(int arga, int argb) {
        Console.WriteLine("MyClass.MethodA called: {0} {1}", arga, argb);
    }
}

class Starter {
    static void Main() {
        MyClass obj = new MyClass();
        XDelegate delObj = new XDelegate(obj.MethodA);
        delObj.Invoke(1, 2);
        delObj(3, 4);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» delegate