Delegate
IT Notes → C# @ December 22, 2020
- It is similar to function pointer and is type safe.
- It dynamically wires up a method caller to its target method.
- It helps in writing plug-in methods.
- A delegate can have more specific parameter types than its method target. This is called contravariance.
- The return type of a delegate can be less specific than the return type of its target method. This is called covariance.
- Func and Action delegates.
- Internally System.Delegate acts as base for System.MulticastDelegate which has target (class = null for static) and method which holds instance of MethodInfo class for the method.
- Anonymous delegate:
delegate del = delegate(params){};
Subscribe
Login
0 Comments