What is a Delegate?

Started by beingchinmay, 11-22-2016, 04:13:12

Previous topic - Next topic

beingchinmayTopic starter

•   Delegate in C# is similar to a function pointer in C or C++.

•   Delegate is type which holds the method(s) reference in an o ject. It is also referred as a type safe function pointers.

•   Delegate allows the programmer to encapsulate a reference to a method inside a delegate object.

•   The delegate object can then be pass d to code which can call the referenced method, without having to know at compile time which m thod will be invok d.

•   An interesting and useful property of a elegate is that it does not know or care about the class of the object that it references.


saravjeet

A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime. Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.