static void Main(string[] args)
        {
            SalDelegate deleg  = new SalDelegate(GetSalary);
            var         salary = deleg.Invoke(30, 800);

            Console.WriteLine("salary = {0}", salary);
            deleg += GetIncentives;    //referencing more than one method
            var incent = deleg.Invoke(30, 800);

            Console.WriteLine("Incentives = {0}", incent);

            //multicaste delegate
            MathDelegate mathdeleg = new MathDelegate(Add);

            mathdeleg += Subtract;
            mathdeleg += Multiply;
            mathdeleg += Divide;


            mathdeleg.Invoke(950, 95);

            Program objP = new Program();

            objP.Print = new printhandler(objP.Onprint); //Registering on print event handler with print event
            objP.show();                                 //raise the print event(defined inside the show method)

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            SalDelegate deleg  = new SalDelegate(GetSalary);
            var         salary = deleg.Invoke(30, 800);

            Console.WriteLine("salary = {0}", salary);
            deleg += GetIncentive;
            var incent = deleg.Invoke(30, 800);

            Console.WriteLine("Incentive = {0}", incent);
        }
        static void Main(string[] args)
        {
            SalDelegate deleg  = new SalDelegate(GetSalary);
            var         salary = deleg.Invoke(30, 800);

            Console.WriteLine("salary = {0}", salary);

            Console.ReadKey();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Program     p = new Program();
            SalDelegate m = new SalDelegate(GetSalary);

            //var sal = m.Invoke(30, 1000);
            // Console.WriteLine("{0}", sal);
            m += Incent;
            // var s = m.Invoke(30,1000);
            // Console.WriteLine("{0}", s);
            m += GetSalary;
            var s1 = m.Invoke(30, 890.45f);

            Console.WriteLine("{0}", s1);
        }