create a class to load an NxN matrix into C #


I do not know how to declare the attribute of the matrix without dimensioning it, since the dimension would be entered by keyboard.

asked by Luna Ortiz 21.06.2016 в 01:02

2 answers


What could be done is the following:

public int[,] cargarMatriz(input1, input2) {
    int[,] matriz = new int[input1, input2];
    return matriz;

Once the user enters the data, there would be a button that executes the function cargaMatriz and this would be the result of your problem.


answered by 21.06.2016 / 02:09

Using static structures, it is not possible. A solution could be knowing the limits of the entries to be handled, in that case you would create a matrix with the dimensions of said limits, and you would only manage the rows and columns up to the inputs that the user provides. The problem with this solution is that it can waste a large amount of memory.

The other solution is to use dynamic structures. In C # there are several that could adapt to the behavior you need, or make your own using nodes.

answered by 21.06.2016 в 01:41