ParamArray

ParamArray allows a function to be passed an arbitrary number of arguments. For example, we could create a function that will take any number of Doubles and return the maximum:

Function Max(ByVal ParamArray Numbers As Double()) As Double

    Dim y As Double = Double.MinValue

    For Each x As Double In Numbers
        If x > y Then y = x
    Next

    Return y
End Function

Sub Main()
    Console.WriteLine(Max(1, 2, 3))
    Console.WriteLine(Max(100, 10, 1000, -12))
    Console.ReadKey()
End Sub

When run, this routine produces the following output:

3
1000