|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to initialize jagged array?an array of two-dimensional arrays. A graphical representation might look like this: x y[a,b] y[a,b] y[a,b] x y[a,b] x y[a,b] y[a,b] x y[a,b] y[a,b] y[a,b] y[a,b] I can initialize a jagged array of arrays like this: string[][] str = new string[][] { new string[] {"loop for strings"}, new string[] {"loop for strings"}, }; which would give me this: x y y y x y x y y x y y y y but how do I initialize the 2-Dim array on the "y" array? I tried this: string[][][,] str = new string[][][,] { new string[] {"loop for strings"}, new string[] {{"loop for strings"}, new string[,] {{"strD-1"}, {"strD-2"}}} }; but no luck. how do I initialize this type of array? Thanks in advance. deko <deko@nospam.com> wrote:
> I trying to create a jagged array of two arrays, with the second array being <snip>> an array of two-dimensional arrays. > > A graphical representation might look like this: > > x y[a,b] y[a,b] y[a,b] > x y[a,b] > x y[a,b] y[a,b] > x y[a,b] y[a,b] y[a,b] y[a,b] > I tried this: No - that's creating an array of arrays of rectangular arrays of > > string[][][,] str = new string[][][,] strings. If you want something with a string and then an array of pairs, I suggest you encapsulate that into your own type. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too >> string[][][,] str = new string[][][,] I think it might be something more like this (still pseudo code):> > No - that's creating an array of arrays of rectangular arrays of > strings. string[][][,] str = new string[3][][,] str[0] = new string[2][,] str[0][0] = new string[,] { { "str00a" }, { "str00b" } } str[0][1] = new string[,] { { "str01a" }, { "str01b" } } str[1] = new string[1][,] str[1][0] = new string[,] { { "str10a" }, { "str10b" } } str[2] = new string[1][,] str[2][0] = new string[,] { { "str20a" }, { "str20b" } } which is intented to be a jagged array of multidimensional arrays. But I'm not sure what the correct syntax is, and how I would fill such a thing in a loop. > If you want something with a string and then an array of pairs, I Yes, that makes sense.> suggest you encapsulate that into your own type. |
|||||||||||||||||||||||