Name: I want to understand 2009-04-26 1:51
Hi.
I am trying to understand rectangular and jagged arrays.
A rectangular array is like a matrix or chessboard, columns and rows are normalized and have no variance.
A jagged array is an array of arrays of varying length.
To loop over a jagged array in my inner loop I need to access the length method of the array stored at: aryInts[i], so I do not access an invalid index. The translation would be:
for (i = 0; i < jagged.Length; i ++)
{
for (j = 0; j < jagged[i].Length; j++)
{
prtln jagged[i][j];
}
}
Is this a rational way to think about this? Do any of you guys have a link to an article for fucking noobs with multi-dim arrays?
Rectangular array:
//skipping decls for rows, columns
int[,] aryInts = new int[row,column];
//to iterate, lets say rows = 8 and columns = 8
for (i = 0; i < 8; i++)
{
for (j = 0; j < 8; j++)
{
prtln(aryInts[i,j]);
}
}I am trying to understand rectangular and jagged arrays.
A rectangular array is like a matrix or chessboard, columns and rows are normalized and have no variance.
A jagged array is an array of arrays of varying length.
To loop over a jagged array in my inner loop I need to access the length method of the array stored at: aryInts[i], so I do not access an invalid index. The translation would be:
for (i = 0; i < jagged.Length; i ++)
{
for (j = 0; j < jagged[i].Length; j++)
{
prtln jagged[i][j];
}
}
Is this a rational way to think about this? Do any of you guys have a link to an article for fucking noobs with multi-dim arrays?