Summary

Delegates are type-safe function pointers that store the address of a Sub or Function, enabling different methods to be invoked at runtime. Delegates are reference types declared via the Delegate keyword; they enable invoking methods via the Invoke method. They can be used in different programming techniques, but the most important scenario where you use delegates is within event-based programming. Events take advantage of delegates in that the objects require their signature to be respected. Coding events is something that can be divided into main areas, such as catching events and exposing events from your objects. To catch events, you can register and deregister via the AddHandler and RemoveHandler keywords, or you can declare objects ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.