Declaring Delegates
A delegate is defined via the Delegate
keyword followed by the method signature it needs to implement. Such a signature can be referred to as a Sub
or as a Function
and might or might not receive arguments. The following code defines a delegate that can handle a reference to methods able to check an email address, providing the same signature of the delegate:
Public Delegate Function IsValidMailAddress(ByVal emailAddress _ As String) As Boolean
Delegates Support Generics
Delegates support generics, meaning that you can define a Delegate Function DelegateName(Of T)
or Delegate Sub DelegateName(Of T)
.
Notice that IsValidMailAddress
is a type and not ...
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.