VB.Net程序设计:Action(Of)代码段

    Dim gcAction As Action = Sub()
                                GC.Collect()
                                GC.WaitForPendingFinalizers()
                            End Sub

'----------------------------
   Dim ac As New Action(Sub()
                           GC.Collect()
                           GC.WaitForPendingFinalizers()
                     End Sub)
   ac()
'--------------------------

    Array.ForEach(New String() {"xx", "mm", "-r"}, action)
    Dim action As New Action(Of String)(AddressOf DPrintString)

    Private Sub DPrintString(s As String)
        Debug.Print(s)
    End Sub


Action 是系统自带的 一个方法,该方法只采用一个参数并且不返回值。

你可能感兴趣的:(2.VB.Net)