Well I'm starting to study the C # language, I have a certain experience in Java, in Java we have a certain problem in array manipulation, because although there is no pointer in the language itself, when it comes to arrays this fear ends up, because when copying an array To example: (matrixA = matrixB). The matrix A ends up recreating the matrix pointer B, so everything that changes in matrix A will change in matrixB. First point wanted to know this problem also occurs in C #. I went to perform a test, but I aim a very stupid problem soon enough that I do not know what the error is.
static void Main()
{
int[,] jogo = new int[2, 2];
jogo[0, 0] = 1;
jogo[0, 1] = 2;
jogo[0, 2] = 3;
jogo[1, 0] = 4;
jogo[1, 1] = 5;
jogo[1, 2] = 6;
jogo[2, 0] = 7;
jogo[2, 1] = 8;
jogo[2, 2] = 9;
int[,] teste = new int[2, 2];
jogo = teste;
Console.WriteLine(teste[0,0]+"|"+ teste[0, 1]+"|"+ teste[0, 2]);
Console.WriteLine(teste[1, 0] + "|" + teste[1, 1] + "|" + teste[1, 2]);
Console.WriteLine(teste[2, 0] + "|" + teste[2, 1] + "|" + teste[2, 2]);
}
For some reason it is giving this error: System.IndexOutOfRangeException: 'The index was outside the bounds of the array.' and I have no idea what I did wrong.