本文整理匯總了VB.NET中System.Action代理的典型用法代碼示例。如果您正苦於以下問題:VB.NET Action代理的具體用法?VB.NET Action怎麽用?VB.NET Action使用的例子?那麽, 這裏精選的代理代碼示例或許可以為您提供幫助。
在下文中一共展示了Action代理的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: ShowValue
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()
MsgBox(Me.instanceName)
End Sub
End Class
Public Module testDelegate
Public Sub Main()
Dim testName As New Name("Koani")
Dim showMethod As ShowValue = AddressOf testName.DisplayToWindow
showMethod
End Sub
End Module
示例2: Name
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()
MsgBox(Me.instanceName)
End Sub
End Class
Public Module testDelegate
Public Sub Main()
Dim testName As New Name("Koani")
Dim showMethod As Action = AddressOf testName.DisplayToWindow
showMethod
End Sub
End Module
示例3: Name
Public Class Name
Private instanceName As String
Public Sub New(name As String)
Me.instanceName = name
End Sub
Public Function DisplayToConsole() As Integer
Console.WriteLine(Me.instanceName)
Return 0
End Function
Public Function DisplayToWindow() As Integer
Return MsgBox(Me.instanceName)
End Function
End Class
Module LambdaExpression
Public Sub Main()
Dim name1 As New Name("Koani")
Dim methodCall As Action = Sub() name1.DisplayToWindow()
methodCall()
End Sub
End Module