參數陣列 (VB.NET)

參數陣列 (VB.NET)

    Sub Main()
        Sum(1, 2)
        Sum(1, 2, 3)
        Sum(Nothing)
    End Sub

    Sub Sum(ByVal ParamArray nums() As Integer)

        If nums Is Nothing Then
            Exit Sub
        End If

        Dim tot As Integer
        For Each i In nums
            tot += i
        Next
        Console.WriteLine("Total : {0}", tot)
    End Sub


如有錯誤 歡迎指正