本文整理汇总了VB.NET中System.Action<T1,T2,T3>代理的典型用法代码示例。如果您正苦于以下问题:VB.NET Action<T1,T2,T3>代理的具体用法?VB.NET Action<T1,T2,T3>怎么用?VB.NET Action<T1,T2,T3>使用的例子?那么, 这里精选的代理代码示例或许可以为您提供帮助。
在下文中一共展示了Action<T1,T2,T3>代理的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: StringCopy
Delegate Sub StringCopy(stringArray1() As String, _
stringArray2() As String, _
indexToStart As Integer)
Module TestDelegate
Public Sub Main()
Dim ordinals() As String = {"First", "Second", "Third", "Fourth", "Fifth"}
Dim copiedOrdinals(ordinals.Length - 1) As String
Dim copyOperation As StringCopy = AddressOf CopyStrings
copyOperation(ordinals, copiedOrdinals, 3)
For Each ordinal As String In copiedOrdinals
Console.WriteLine(ordinal)
Next
End Sub
Private Sub CopyStrings(source() As String, target() As String, startPos As Integer)
If source.Length <> target.Length Then
Throw New IndexOutOfRangeException("The source and target arrays must have the same number of elements.")
End If
For ctr As Integer = startPos to source.Length - 1
target(ctr) = String.Copy(source(ctr))
Next
End Sub
End Module
示例2: TestAction3
Module TestAction3
Public Sub Main()
Dim ordinals() As String = {"First", "Second", "Third", "Fourth", "Fifth"}
Dim copiedOrdinals(ordinals.Length - 1) As String
Dim copyOperation As Action(Of String(), String(), Integer) = AddressOf CopyStrings
copyOperation(ordinals, copiedOrdinals, 3)
For Each ordinal As String In copiedOrdinals
Console.WriteLine(ordinal)
Next
End Sub
Private Sub CopyStrings(source() As String, target() As String, startPos As Integer)
If source.Length <> target.Length Then
Throw New IndexOutOfRangeException("The source and target arrays must have the same number of elements.")
End If
For ctr As Integer = startPos to source.Length - 1
target(ctr) = String.Copy(source(ctr))
Next
End Sub
End Module
示例3: TestLambda
Public Module TestLambda
Public Sub Main()
Dim ordinals() As String = {"First", "Second", "Third", "Fourth", "Fifth"}
Dim copiedOrdinals(ordinals.Length - 1) As String
Dim copyOperation As Action(Of String(), String(), Integer) = _
Sub(s1, s2, pos) CopyStrings(s1, s2, pos)
copyOperation(ordinals, copiedOrdinals, 3)
For Each ordinal As String In copiedOrdinals
If String.IsNullOrEmpty(ordinal) Then
Console.WriteLine("<None>")
Else
Console.WriteLine(ordinal)
End If
Next
End Sub
Private Function CopyStrings(source() As String, target() As String, startPos As Integer) As Integer
If source.Length <> target.Length Then
Throw New IndexOutOfRangeException("The source and target arrays must have the same number of elements.")
End If
For ctr As Integer = startPos To source.Length - 1
target(ctr) = String.Copy(source(ctr))
Next
Return source.Length - startPos
End Function
End Module
输出:
Fourth Fifth