예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
 public Employee(EmpDel method)
 {
     obj = method;
 }