Exemplo n.º 1
0
        static void Main(string[] args)
        {
            del_invoca handler = DelegateMethod;

            MethodWithCallback(1, 2, handler); //The number is: 3

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Instantiate the delegate.
            del_invoca handler = DelegateMethod;

            // Call the delegate.
            handler("Hello World");


            //O delegado também pode ser chamado usando o método.invoke.
            handler.Invoke("Ali Asad");

            List <del_Calculate> function = new List <del_Calculate>();

            Console.ReadKey();
        }
Exemplo n.º 3
0
 static public void MethodWithCallback(int param1, int param2, del_invoca callback)
 {
     callback("The number is: " + (param1 + param2).ToString());
 }