Action Delegate encapsulates a method that has no parameters and does not return a value.
Public Delegate Sub ShowValue
Public Class Name
Private instanceName As String
Public Sub New(name As String)
Me.instanceName = name
End Sub
Public Sub DisplayToConsole()
Console.WriteLine(Me.instanceName)
End Sub
Public Sub DisplayToWindow()
Console.WriteLine(Me.instanceName)
End Sub
End Class
Public Module testDelegate
Public Sub Main()
Dim testName As New Name("String")
Dim showMethod As ShowValue = AddressOf testName.DisplayToWindow
showMethod
End Sub
End Module
Related examples in the same category