The value in all arrays C # is changed

0

Hello, I would like your help or see if anyone knows what is happening, when reading the data in an excel file I keep it in an array and I keep two more to perform other procedures with them, but when modifying one the others are modified two, someone knows why this happens, thank you.

                    var resultadoExcel = openExcel.Result(item);
                    var libro          = resultadoExcel.Item1;
                    var libro3         = resultadoExcel.Item1;
                    var filas          = resultadoExcel.Item2;
                    var columnas       = resultadoExcel.Item3;

                    var heuristica2 = libro;
                    var capacidad   = libro[2, 1];
                    var articulos   = libro[2,2];
                    resultBox.Text  += "Capacidad Máxima:" + Convert.ToString(capacidad);
                    resultBox.Text  += ("\r\n");


                    libro[0, 0] = 1; // Al hacer este cambio se modifica en todos

When the change is made in the book variable, the variable book3 and heuristica2 are also affected.

    
asked by Ramses Pacheco 18.02.2018 в 17:39
source

0 answers