本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System,代码行数:24,代码来源:Action
示例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
开发者ID:VB.NET开发者,项目名称:System,代码行数:20,代码来源:Action
示例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
开发者ID:VB.NET开发者,项目名称:System,代码行数:27,代码来源:Action 输出:
Fourth
Fifth
注:本文中的System.Action<T1,T2,T3>代理示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论