Simple Problem, but I can't find an answer. I already asked this question but it has been marked as a duplicate to "What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?" Which is a solution I have already read and not found an answer in. Please help, much thanks.
public static int tileValue;
public static int layers;
public static int rows;
public static int columns;
static public int Layer;
static public int Row;
static public int Col;
static public int[,,] map = new int[Layer, Row, Col];// <<<<<<<<<<<<<<<<<<< FIX THIS, i dont make it??
public static int Level(int layer, int row, int column)
{
int tileIndex = 0;
if (Layer == 2 && Row == 10)
{
//map.SetValue(4, layers, rows, columns);
tileIndex = (int)map.GetValue(0, 0, 0);
}
return tileIndex;
}
I have no idea why I am getting a System.IndexOutOfRangeException. I tested with the variable of Layer, Row and Col to 2, 10, 10, which is why I had the if condition and the code only works if I put in the numbers manually. As,
static public int[,,] map = new int[2, 10, 10];
the Level method tileindex (for now) checks the value of 0,0,0; the smallest value to check and returns the value to a different class. Yet, I still receive the error. I know the problem is with my
static public int[,,] map = new int
Because it only works when I manually input it. And I used the if condition to see if the numbers were inputing well, and they are... So solutions?