static void Main() { Employee eobj = new Employee(); EmpDel ed1 = new EmpDel(Employee.AcceptEmployee); // static method being given to a delegate Object ed1(" Hi Radha"); EmpDel ed2 = new EmpDel(eobj.DisplayEmployee); // Instance method being given to a delegate Object ed2("Welcome to The World of Delegates"); Console.Read(); }
public static void Main(string[] args) { Employee eobj = new Employee(); EmpDel ed1 = new EmpDel(Employee.AcceptEmployee); //static method being given to a delegate ed1("Radha"); EmpDel ed2 = new EmpDel(eobj.DisplayEmployee); //nonstatic method being given to a delegate ed2("Delegate Radha here"); Console.ReadKey(); }
static void Main() { Employee emp = new Employee(); EmpDel eda = new EmpDel(Employee.Accept); //static method so classname is used eda("Bhupesh"); EmpDel edd = new EmpDel(emp.Display); //non static so instance is used edd("Welcome to C# delegates"); Console.Read(); }
public Employee(EmpDel method) { obj = method; }