How to use ParamArray to that create array from numbers send to subroutine (sub) in VB.NET

1 Answer

0 votes
Module Module1

    Sub Main()

        PrintArray()
        PrintArray(5)
        PrintArray(98, 8)
        PrintArray(3, 45, 2)
        PrintArray(999, 34, 1, 9283)

    End Sub

    Sub PrintArray(ParamArray arr() As Integer)

        Console.WriteLine("Array Length: " + arr.Length.ToString())

        For Each n As Integer In arr
            Console.WriteLine(n)
        Next
    End Sub

End Module


' run:
' 
' Array Length: 0
' Array Length :  1
' 5
' Array Length :  2
' 98
' 8
' Array Length :  3
' 3
' 45
' 2
' Array Length :  4
' 999
' 34
' 1
' 9283

 



answered Oct 20, 2018 by avibootz

Related questions

1 answer 238 views
1 answer 207 views
1 answer 221 views
1 answer 190 views
2 answers 112 views
1 answer 212 views
212 views asked Mar 28, 2019 by avibootz
...