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 O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.