
We learned about the event driven approach and the need of a contract to define a method signature. The .NET message signature type is called delegate and it helps us to store 1 or more methods with the same (exact) signature. Why? so we can Invoke these methods (stored in the delegate) whenever we want to (usually when an event occurs, for example: button-Click). We saw the Action<T> type and the Func<T> type which are actually a delegate wrappers. we understood the loosely couple concept in which we can take two non-related classes and bind them together using the delegate (and unbind them). Finally we saw how to create a delegate method using Lambda expression
More topics covered:
- Publish-Subscriber
- Creating Property of a delegate member
- Using the delegate type as a method parameter
- Using the delegate type as a method return value
- Executing delegate using Invoke and without Invoke
- Delegate can actually store 1 or more methods
- Invoking a delegate execute all of the stored methods
Links: