Imports System
Public Class Program
Public Shared Function AddColumn(ByVal original As Integer(,), ByVal new_col As Integer()) As Integer(,)
Dim lastRow As Integer = original.GetUpperBound(0)
Dim lastColumn As Integer = original.GetUpperBound(1)
Dim new_arr2d As Integer(,) = New Integer(lastRow + 1 - 1, lastColumn + 2 - 1) {}
For i As Integer = 0 To lastRow
For j As Integer = 0 To lastColumn
new_arr2d(i, j) = original(i, j)
Next
Next
For i As Integer = 0 To new_col.Length - 1
new_arr2d(i, lastColumn + 1) = new_col(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 = AddColumn(arr2d, New Integer() {7, 8})
PrintArray(arr2d)
End Sub
End Class
' run:
'
' 1 2 3 7
' 3 4 6 8
'