Application Development Using Visual Basic® and .NET
by Robert J. Oberg, Peter Thorsteinson, Dana L. Wyatt
Delegates
Interfaces facilitate writing code so that your program can be called into by some other code. This style of programming has been available for a long time, under the guise of “callback” functions. In this section we examine delegates in VB.NET, which can be thought of as type-safe and object-oriented callback functions. Delegates are the foundation for a design pattern, known as events, which we'll look at in the next section.
A callback function is one which your program specifies and “registers” in some way, and which then gets called by other code. In C and C++ callback functions are implemented using function pointers.
In VB.NET you can encapsulate a reference to a method as a delegate object. A delegate can refer to either a static ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access