How to print a specific column of a matrix in VB.NET

1 Answer

0 votes
Imports System
 
Public Class PrintSpecificColumnOfMatrix_VB
    Public Shared Sub printColumnOfMatrix(ByVal matrix As Integer(,), ByVal col As Integer)
		Dim rows As Integer = matrix.GetLength(0)
		
        For i As Integer = 0 To rows - 1
            Console.Write(matrix(i, col) & " ")
        Next
    End Sub
 
    Public Shared Sub Main(ByVal args As String())
        Dim matrix As Integer(,) = New Integer(,) {
        {3, 2, 5, 1},
        {4, 7, 6, 5},
        {9, 3, 0, 1}}
     
        printColumnOfMatrix(matrix, 1)
    End Sub
End Class
 
 
 
' run:
'
' 2 7 3
'

 



answered Jul 12, 2024 by avibootz
edited Jul 13, 2024 by avibootz
...