Reputation: 214
when trying to use a loop to create a jagged array, but what happens is I get an IndexOutOfRangeException when i and j are 0. Here is the code
double[,][] coords = new double[,][] { };
for (int i = 0; i <= p; i++)
{
for (int j = 0; j <= q; j++)
{
coords[i, j] = new double[4] { (4 things in here) };
}
}
I have read this: http://www.daniweb.com/software-development/java/threads/360615 but do not know how to apply it to this.
Solution: changed from "double[,][] coords = new double[,][] { };" to "double[,][] coords = new double[p,q][];" Thanks!
Upvotes: 1
Views: 282
Reputation: 12366
You need to instantiate your array size, from your code I assume this would be correct size.
double[,][] coords = new double[p+1,q+1][];
Upvotes: 3