Action Delegate encapsulates a method that has no parameters and does not return a value. : Action « Language Basics « VB.Net






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

1.Action(T1, T2) Delegate represents a method that has two parameters and does not return a value.