FAQs of level

A delegate is a type safe function pointer. Using delegates you can pass methods as parameters. To pass a method as a parameter, to a delegate, the signature of the method must match the signature of the delegate. This is why, delegates are called type safe function pointers.

Delegates are mainly used to define call back methods. There are two basic uses of delegates:

  • Callbacks / events.
  • Method and function abstraction.

If we want one delegate to point to multiple methods / function we use multicast delegates.

Delegate declaration determines the methods that can be referenced by the delegate. A delegate can refer to a method, which has the same signature as that of the delegate.

For example, consider a delegate:

public delegate int MyDelegate (string s);

The preceding delegate can be used to reference any method that has a single string parameter and returns an int type variable.

Syntax for delegate declaration is:

delegate <return type> <delegate-name> <parameter list>

Need Help? Contact Us.

Log in


Forgot password?


New User