Define Delegate - DOT.NET

Define Delegate.

- Delegates are kind of similar to the function pointers. But they are secure and type-safe.

- A delegate instance encapsulates a static or an instance method.

- Declaring a delegate defines a reference type which can be used to encapsulate a method having a specific signature.

- Delegate is a type which holds a reference to a method.

- It is declared with a signature that shows the return type and parameters for the methods it references.

- It can hold references, only methods that match its signature.

- It is equivalent to a type-safe function pointer or callback.

Declaration of Delegates:
public delegate int MyDelegate (String s);

- It is used for implementing events and the call-back methods.

- All the delegates are implicitly derived from the System.Delegate class.
What is the purpose of AddHandler keyword? - DOT.NET
The AddHandler statement allows you to specify an event handler...
Describe how exceptions are handled by the CLR - DOT.NET
Usually the exceptions that occur in the try are caught in the catch block....
How to throw a custom exception? - DOT.NET
The usual try - catch - finally - ent try format has to be followed....
Post your comment