//delcare my delegate object
        static void Main(string[] args)
        {
            SomeMethodPointer pointer = new SomeMethodPointer(SomeMethod); //pointing the delegate to the "Some Method"
            pointer.Invoke(); // Calling the method that the delegate is pointed to.

            //above is the old way.. here is the new
            SomeMethodPointer pointerTwo = SomeMethod; // this is much simpler way of method assignment
        }
Ejemplo n.º 2
0
        public delegate void SomeMethodPointer(); //delcare my delegate object

        static void Main(string[] args)
        {
            SomeMethodPointer pointer = new SomeMethodPointer(SomeMethod); //pointing the delegate to the "Some Method"

            pointer.Invoke();                                              // Calling the method that the delegate is pointed to.

            //above is the old way.. here is the new
            SomeMethodPointer pointerTwo = SomeMethod; // this is much simpler way of method assignment
        }
Ejemplo n.º 3
0
        public static void launchExample()
        {
            SomeMethodPointer obj1;

            obj1 = SomeMethod;

            //or do not need to declare the delegate above Action is a delegate that returns void and accepts no parameters
            Action obj2;

            obj2 = SomeMethod;

            //or

            SomeMethodPointer obj3 = new SomeMethodPointer(SomeMethod);

            obj1.Invoke();
            obj2.Invoke();
            obj3.Invoke();
        }