Problem
I am writing a Matrix class in C# and I know that this class needs a two dimension array to store the Matrix object. The constructor for my Matrix class takes two parameters, the m and n dimensions of the Matrix. I have tried to assign the array inside the constructor but I get the error that
Invalid Rank Specifier
. The code I tried is listed below.
class Matrix
{
//make the dimensions private
private int m,n;
//The Matrix constructor needs two parameters
//The row and column dimensions
//declare the two dimension array
private int[][] array;
public Matrix(int m, int n) {
//assign the array inside the constructor
array = new int[m][n];
}
//method to allocate the Matrix
}
My goal is to initialize the array with the dimensions first so that assigning can be done without errors, Thank You.