Types of delegates in c
- how to invoke delegate in c
- how to call delegate in c
C# delegate example.
Delegates (C# Programming Guide)
A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type.
You can invoke (or call) the method through the delegate instance.
Delegates are used to pass methods as arguments to other methods. Event handlers are nothing more than methods that are invoked through delegates.
You create a custom method, and a class such as a windows control can call your method when a certain event occurs. The following example shows a delegate declaration:
Any method from any accessible class or struct that matches the delegate type can be assigned to the delegate.
Multicast delegates in c
The method can be either static or an instance method. This flexibility means you can programmatically change method calls, or plug new code into existing classes.
Note
In the context of method overloading, the signature of a method does not include the return value.
But in the context of delegates, the signature does include the
- how to invoke a delegate method c