[RESOLVED] 3 Dimensional arrays...
Ok, I just had the same problem in Python, and I know I always used to mix this in C++ and C# too, so it is probably much simpler then it looks like right now.
What I want to know is the syntax to first make a 2D array. Then I want to make a an other one dimensional array, and make one of the elements in the first one point to the other array, something like:
my2DArray[2,2] = my1DArray;
my2DArray[2,3] = anOther1DArrray;
is this doable..:)..if so, how? Jagged array or?
- ØØ -
Re: [RESOLVED] 3 Dimensional arrays...
This looks pretty stupid, but at least it looks like it works...
Code:
TestObj[][][] test;
test = new TestObj[4][][];
test[0] = new TestObj[4][];
test[0][1] = new TestObj[10];
test[0][1][7] = new TestObj();
test[0][1][7].X = 3;
- ØØ -
Re: [RESOLVED] 3 Dimensional arrays...
int[] One = new int[10];
int[,] Two = new int[10,10];
Two[0,0] = One[0];
Two[0,1] = One[1];
Two[0,2] = One[2];
Two[0,3] = One[3];
...
?????
According to MSDN, jagged arrays are much more efficiently handled by the CLR than normal rectangular arrays.
Re: [RESOLVED] 3 Dimensional arrays...
But what you did now is not a 3D array. It is a 2D array...
What you would have to do is this:
int[] One1 = new int[10];
int[] One2 = new int[10];
int[] One3 = new int[10];
int[,] Two = new int[10,10];
Two[0,0] = One1;
Two[0,1] = One2;
Two[0,2] = One3;
How would you do that with jagged arrays? It is har to find the right syntax here since you can't see the difference on a one dimentional jagged array or a one dimmentional normal array....hmmm-.....
- ØØ -
Re: [RESOLVED] 3 Dimensional arrays...
HAhaha...light just got turned on..:D
Code:
int[] One = new int[10];
int[,][] Two = new int[10, 10][];
Two[0, 0] = One;
Ugly as hell, but it looks like it is working..:)
PS: I have lost the count on how many times I should rate you though...:D
- ØØ -
Re: [RESOLVED] 3 Dimensional arrays...
Ahhhhhh now I see what you wanted.
I have also lost count of how many times you should have rated me. :lol:
I still need to spread the love before I can hit you again though.
Re: [RESOLVED] 3 Dimensional arrays...
Hehe..yeah...the spread is always a pain in the ass...but at least this is working now...but the 3D point -> polygon code is not...grrrrrrrr...you have NOOO idea how many pieces of papers I have used for this project...grrr..:)
- ØØ -