Imports System
Public Class Program
Public Shared Function AddRow(ByVal arr As Integer(,), ByVal new_row As Integer()) As Integer(,)
Dim lastRow As Integer = arr.GetUpperBound(0)
Dim lastColumn As Integer = arr.GetUpperBound(1)
Dim new_arr2d As Integer(,) = New Integer(lastRow + 2 - 1, lastColumn + 1 - 1) {}
For i As Integer = 0 To lastRow
For j As Integer = 0 To lastColumn
new_arr2d(i, j) = arr(i, j)
Next
Next
For i As Integer = 0 To new_row.Length - 1
new_arr2d(lastRow + 1, i) = new_row(i)
Next
Return new_arr2d
End Function
Public Shared Sub PrintArray(ByVal array As Integer(,))
For i As Integer = 0 To array.GetUpperBound(0)
For j As Integer = 0 To array.GetUpperBound(1)
Console.Write(array(i, j) & " ")
Next
Console.WriteLine()
Next
End Sub
Public Shared Sub Main()
Dim arr2d As Integer(,) = {
{1, 2, 3},
{3, 4, 6}}
arr2d = AddRow(arr2d, New Integer() {7, 8, 9})
PrintArray(arr2d)
End Sub
End Class
' run:
'
' 1 2 3
' 3 4 6
' 7 8 9
'