Steps to create a delegate:

  1. Create a class with methods.

    E.g.:     class test

        {

            public void print ()

            {

            }

        }

  2. Create a delegate.

    Syntax:     

    public delegate <return_type_of_method> <delegate_name >();

    E.g.:    public delegate void xyz ();

  3. Create an object for delegate with the address of class method.

    E.g.:    test t =new test;

        xyz x = new xyz (t.print);

  4. Invoke or class the delegate.

    E.g.:    x ();

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger