There a section in my code where I need to invert a matrix. That can only reasonably be done on a square matrix, in this case a 3x3 square matrix. The tool I'm using to invert the matrix kept saying that my array wasn't a proper square.
So I did a little test:
double[,] x = new double[3, 3];
MessageBox.Show(x.GetLength(0).ToString());
MessageBox.Show(x.GetLength(1).ToString());
MessageBox.Show(x.GetLength(2).ToString());
First one comes up as "3". Second one comes up as "3". Third one comes up as an IndexOutOfRangeException
. Am I just overlooking something extremely obvious or... is this a little weird?
(Note: This is code from C# using .Net 2.0)