Reversing a matrix in C#
I also changed the Reversal code and got rid of all the variables.  from the looks of it you did what I did only you did it with out the use of for loops

I used one loop to go through the rows(or the first dimension of the multi-dimensional array) and then I nested a second loop inside the first to loop through the elements of each array.   now in doing this I needed some independent variables to be incremented for the output matrix so I made sure that I declared them in the right places and incremented them in the right places.   the output matrix was declared using the input matrix so that I didn't have to declare any magic numbers and so that I could minimize the number of variables that I had to declare as well.

enough chit chat here is the code.

    static int[,] ReverseMatrix(int[,] inputMatrix)
    {
        var outputMatrix = new int[inputMatrix.GetLength(0), inputMatrix.GetLength(1)];
        var x = 0;
        for (int i = inputMatrix.GetLength(0) - 1; i &gt;= 0; i--)
        {
            var y = 0;
            for (int j = inputMatrix.GetLength(1) - 1; j &gt;= 0; j--)
            {
                outputMatrix[x, y] = inputMatrix[i, j];
                y++;
            }
            x++;
        }
        return outputMatrix;
    }


Posted as a question also Reversing a Matrix



one thing that I did differently was that I used an input and an output for my method, I personally don't like the way that your code changes a variable outside of the scope like that, if the purpose were to change the original then I wouldn't change my code at all, I would just change how I call the code, I would do it like this

matrix = ReverseMatrix(matrix);


I don't like the way that you did it, I am sure there is a reason for it and a good and bad way to do it, but I don't think this is a good place to use code like this.