Home All Groups Group Topic Archive Search About

2 dimensional arrays collection - how to?

Author
9 Apr 2005 11:39 AM
Macin
Hi,

I need to create a collection of 2 dimensional arrays. How can I do this?
What type of collection?

And the second question would be, how can I then display all of the small
arrays at once as showed below?

One, two dimensional array:
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx


I want to dispaly them like this, after they all are in a collection.

                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx

                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
                xxxxxxxxx    xxxxxxxxx    xxxxxxxxx

and so on...

Has anyone got any idea???
Thanks

Author
10 Apr 2005 9:08 AM
Lebesgue
ArrayList listOf2DArrays = new ArrayList();
object[,] my2DArray = GetItFromSomewhere();
listOf2DArrays.Add(my2DArray);

if you would like to encapsulate some functionality into the arrays,
consider writing a wrapper class for it
just like
class Wrapper
{
private ArrayList arrays;
private object[,] arr;

....
public override string ToString()
{
StringBuilder sb = new StringBuilder();
//iterate the ArrayList and build the string output on the stringbuilder
like
xxx xxx
xxx xxx
xxx xxx
}
}

Show quoteHide quote
"Macin" <mar***@iv.pl> wrote in message
news:OefnFjPPFHA.1176@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I need to create a collection of 2 dimensional arrays. How can I do this?
> What type of collection?
>
> And the second question would be, how can I then display all of the small
> arrays at once as showed below?
>
> One, two dimensional array:
> xxxxxxxxx
> xxxxxxxxx
> xxxxxxxxx
> xxxxxxxxx
>
>
> I want to dispaly them like this, after they all are in a collection.
>
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>                 xxxxxxxxx    xxxxxxxxx    xxxxxxxxx
>
> and so on...
>
> Has anyone got any idea???
> Thanks
>
>

Bookmark and Share