C
C#15mo ago
Jens I

❔ 3D Arrays = good tutorial?

Does someone have a good guide/tutorial how to explain 3d arrays. the course on udemy isnt to clear for me . what of the 3 axes is wich? ( z, x , y) How does it move , etc.
14 Replies
ero
ero15mo ago
3D arrays? you mean int[,,], yes?
Jens I
Jens IOP15mo ago
yes multi dimensional arrays . [,,] is correct
ero
ero15mo ago
then it's your choice what goes where
Jens I
Jens IOP15mo ago
wdym?
ero
ero15mo ago
well, you're the one populating it it's just an array you can put anything you want in it
int[,,] foo =
{
{
{ 1, 2, 3 },
{ 4, 5, 6 }
},
{
{ 7, 8, 9 },
{ 0, int.MaxValue, int.MinValue }
}
};
int[,,] foo =
{
{
{ 1, 2, 3 },
{ 4, 5, 6 }
},
{
{ 7, 8, 9 },
{ 0, int.MaxValue, int.MinValue }
}
};
this could be x, y, z, y, z, x, foo, bar, baz, p, _9999, Γ
Jens I
Jens IOP15mo ago
yeah but i mean, whats the index of those numbers
ero
ero15mo ago
foo[0, 0, 0] i see where you might be confused. the 0 here would be at foo[1, 1, 0]
Jens I
Jens IOP15mo ago
and how do they increase ?
ero
ero15mo ago
well the first index is the outermost array. the second is the next layer, and the last is the final array it's an array of arrays of arrays
Jens I
Jens IOP15mo ago
yeah [,] = like 00 0102 10 11 12 so if you added one more { } then it would be 1 0 0
Jens I
Jens IOP15mo ago
figured it out myself
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server