Relaxed Delegates

When you code methods that are pointed to by delegates, your methods must respect the delegate’s signature. An exception to this rule is when your method receives arguments that are not effectively used and therefore can be omitted. Such a feature is known as relaxed delegates. The simplest example to help you understand relaxed delegates is to create a Windows Forms application. After you’ve created your application, drag a Button control from the toolbox onto the form’s surface. Double-click the new button to activate the code editor so that Visual Studio generates an event handler stub for you and type the following code:

As you can see, the method body simply shows a text message but does not make use of both sender

Get Visual Basic® 2010 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.