本文整理汇总了VB.NET中System.Action<T1,T2,T3,T4>代理的典型用法代码示例。如果您正苦于以下问题:VB.NET Action<T1,T2,T3,T4>代理的具体用法?VB.NET Action<T1,T2,T3,T4>怎么用?VB.NET Action<T1,T2,T3,T4>使用的例子?那么, 这里精选的代理代码示例或许可以为您提供帮助。
在下文中一共展示了Action<T1,T2,T3,T4>代理的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: StringCopy
Delegate Sub StringCopy(stringArray1() As String, _
stringArray2() As String, _
indexToStart As Integer, _
numberToCopy As Integer)
Module TestDelegate
Public Sub Main()
Dim ordinals() As String = {"First", "Second", "Third", "Fourth", _
"Fifth", "Sixth", "Seventh", "Eighth", _
"Ninth", "Tenth"}
Dim copiedOrdinals(ordinals.Length - 1) As String
Dim copyOperation As StringCopy = AddressOf CopyStrings
copyOperation(ordinals, copiedOrdinals, 3, 5)
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, number 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 startpos + number - 1
target(ctr) = String.Copy(source(ctr))
Next
End Sub
End Module
示例2: TestAction4
Module TestAction4
Public Sub Main()
Dim ordinals() As String = {"First", "Second", "Third", "Fourth", _
"Fifth", "Sixth", "Seventh", "Eighth", _
"Ninth", "Tenth"}
Dim copiedOrdinals(ordinals.Length - 1) As String
Dim copyOperation As Action(Of String(), String(), Integer, Integer) = _
AddressOf CopyStrings
copyOperation(ordinals, copiedOrdinals, 3, 5)
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, number 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 startpos + number - 1
target(ctr) = String.Copy(source(ctr))
Next
End Sub
End Module
示例3: TestLambdaExpression
Public Module TestLambdaExpression
Public Sub Main()
Dim ordinals() As String = {"First", "Second", "Third", "Fourth", "Fifth", _
"Sixth", "Seventh", "Eighth", "Ninth", "Tenth"}
Dim copiedOrdinals(ordinals.Length - 1) As String
Dim copyOperation As Action(Of String(), String(), Integer, Integer) = _
Sub(s1, s2, pos, num) CopyStrings(s1, s2, pos, num)
copyOperation(ordinals, copiedOrdinals, 3, 5)
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, number 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 startPos + number - 1
target(ctr) = String.Copy(source(ctr))
Next
Return number
End Function
End Module
输出:
Fourth Fifth Sixth Seventh Eighth