本文整理汇总了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