Fabulous Adventures In Coding
Eric Lippert is a principal developer on the C# compiler team. Learn more about Eric.
reader asked "Why
are there two types of multidimentional arrays? What is the difference between the (x)(y) and (x,y) notation?"
question. There are two kinds of multidimensional
arrays, called "rectangular" and "ragged". A
rectangular array is, well, rectangular. You
you get an array with indices:
makes a nice rectangle. A three-dimensional
array makes a rectangular prism, and so on up into the higher dimensions.
as I mentioned earlier, JScript does not have multidimensional arrays. A
clever trick to simulate multidimensional arrays is to make an array of arrays:
x = new Array(
Array(1, 2, 3),
Array(6, 7, 8, 9));
so dereferencing the outer array gives you the inner array, which can then be dereferenced
you notice something about the indices if we write them out as before:
  
indices make a ragged pattern, not a straight rectangular pattern.
can have ragged higher dimensional arrays as well, though allocating all the sub-arrays
gets to be a royal pain.
are often times when you want ragged arrays even in a language that supports rectangular
multi-dimensional arrays, so VBScript supports both. If
you are talking to a rectangular two-dimensional array. If
you are talking to a one dimensional array that contains another one dimensional array.
I feel lucky to have found your article "Running Me Ragged " on google today.
I was desperately looking for information on ragged arrays in vbscript.
I was trying to achieve a dynamic 3rd dimension for every 1st dimension element in my 3-dimensional rectangular array but it was just not working and now I know why thanks to your article.
I want to use a ragged 3 dimensional array for the above solution instead but am not sure how.
Would you be able to suggest a few links or a book where I can find an example of the ragged 3 dimensional arrays and how to use them?
PingBack from http://www.aaronpalermo.com/wordpress/archives/11
i need some help..
i wasted a lot of time while searching on the internet about my problem and i am not sure if i am writing on the correct place.
My problem is ;
** i am a vb 6.0 user
i have a 3D-D array
and i want to redim. it but i dont want to use a prism. So ;
i assigned NJ(1)=10 ; NJ(2)=14; NJ(3)=5
NI(1)=10 ; NI(2)=18; NI(3)=5 and i want to redim myarray like ;
for computing economy i dont need want to dim. my array like ; redim myarray(3,14,18)
how can i do that ?
thanks ; Tolga