O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required