Sub PrintValues(ParamArray values() As Integer)
' Display Length of array.
Console.WriteLine("Count: " + values.Length.ToString())
' Loop over ParamArray values.
For Each value As Integer In values
' Use ParamArray method.
PrintValues(10, 20, 30)
End ModuleCount: 0
Some notes. Performance is not everything. For simplicity, using ParamArray for a varargs Function is a good plan. Often the array overhead will not matter.
A review. ParamArray is the same construct as "params" in C#. Other languages have similar constructs, sometimes referred to as varargs for "variadic" or "variable" argument lists.
Dot Net Perls is a collection of tested code examples. Pages are continually updated to stay current, with code correctness a top priority.
Sam Allen is passionate about computer languages. In the past, his work has been recommended by Apple and Microsoft and he has studied computers at a selective university in the United States.
This page was last updated on Dec 16, 2021 (edit link).