Home > DeveloperSection > Blogs > Concept of Delegates

Concept of Delegates

0 Comment(s)
 1511  View(s)
Rate this:

Delegates are references to methods. So we have used to references to object, e.g.

Employee emp = new Employee ();

Here emp is a reference to an object of the Employee class type. Hence, each reference has two properties:

1.       The type of object (class) the reference can point to.

2.       The actual object referenced (or pointed to) by the reference.

Delegates are similar to object references, but are used to reference methods instead of objects. The type of a delegate is type or signature of the method rather than class. Hence a delegate has three properties:

·         The type or signature of the method that the delegate can point to

·         The delegate reference which can we used to reference a method

·         The actual method referenced by the delegate

The concept of delegates is similar to the function pointers used in C++

Don't want to miss updates? Please click the below button!

Follow MindStick