當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET Action代理代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:25,代碼來源:Action

示例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
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:23,代碼來源:Action

示例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
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:24,代碼來源:Action


注:本文中的System.Action代理示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。