Public Class Matriz5
Private mat(,) As Integer
Public Sub Cargar()
Dim filas, columnas As Integer
Console.Write("Cuantas fila tiene la matriz:")
filas = Console.ReadLine()
Console.Write("Cuantas columnas tiene la matriz:")
columnas = Console.ReadLine()
ReDim mat(filas - 1, columnas - 1)
Dim f, c As Integer
For f = 0 To mat.GetUpperBound(0)
For c = 0 To mat.GetUpperBound(1)
Console.Write("Ingrese componente:")
mat(f, c) = Console.ReadLine()
Next
Next
End Sub
Public Sub Imprimir()
Dim f, c As Integer
For f = 0 To mat.GetUpperBound(0)
For c = 0 To mat.GetUpperBound(1)
Console.Write(mat(f, c) & " ")
Next
Console.WriteLine()
Next
End Sub
Public Sub ImprimirUltimaFila()
Dim c As Integer
Console.WriteLine("Ultima fila")
For c = 0 To mat.GetUpperBound(1)
Console.Write(mat(mat.GetUpperBound(0), c) & " ")
Next
End Sub
End Class
Sub Main()
Dim ma As New Matriz5()
ma.Cargar()
ma.Imprimir()
ma.ImprimirUltimaFila()
Console.ReadKey()
End Sub
(03-01-2022, 12:22)jguardon escribió: arrays multidimensionales,
[hr]
[quote='dariodr' pid='4236' dateline='1641214822']
ReDim
[/quote]
Parecería corresponder al Método ". Resize()" de la Clase [i]Array[/i].
Pero las matrices multidimensionales no pueden ser redimensionadas:
https://gambaswiki.org/wiki/comp/gb/array/resize?l=es
Yo adoptaría esta estratagema:
[code]
Public Sub Main()
Dim a, b As Integer
a = 4
b = 5
mat = New Integer[a, b]
Print mat.Bounds[0] ' Parecido a "mat.GetUpperBound(0)"
Print mat.Bounds[1] ' Parecido a "mat.GetUpperBound(1)"
End