Exemplo n.º 1
0
        public void SimpleDelegateFromMethod()
        {
            Delegates   target = new Delegates();
            Int32Action action = new Int32Action(target.RandomRob);

            action.Invoke(10);
        }
        public void DelegateFromSaticMethod()
        {
            Delegates target = new Delegates();
            Int32Action action = new Int32Action(Delegates.StaticRob);

            action.Invoke(7);
        }
        public void SingleDelegateMethodFromMethod()
        {
            Delegates target = new Delegates("John");
            Int32Action action = new Int32Action(target.RandomRob);

            action.Invoke(5);
            action(6);
        }
        public void Method_Can_Be_Invoked_Via_Delegate()
        {
            var target = new Target("Jon");
            var action = new Int32Action(target.RandomRob);

            action.Invoke(5); //Invoke can be omitted.
            action(6);
        }
Exemplo n.º 5
0
        public void SimpleDelegatesFromMethod()
        {
            var         mytarget = new Delegates();
            Int32Action action   = mytarget.DoIt;

            Int32Action action2 = action + mytarget.RandomRob;

            action2.Invoke(4);
        }
Exemplo n.º 6
0
        public void SimpleDelegateFormMethod()
        {
            Delegates   target = new Delegates();
            Int32Action action = new Int32Action(target.RandomRob);

            action.Invoke(5);
            action(6);

            var person = new
            {
                Name         = "Obinna",
                EmailAddress = "*****@*****.**"
            };

            Console.WriteLine(person.ToString());
        }
Exemplo n.º 7
0
        public void DeligateStaticMethod()
        {
            Int32Action action = new Int32Action(Delegates.StaticRob);

            action.Invoke(7);
        }
Exemplo n.º 8
0
        public void DelegateFromStaticMethod()
        {
            Int32Action action = new Int32Action(Delegates.StaticRob1);

            action.Invoke(8);
        }