multidimensional arrays and array lists

R

Rob

Hi,

I want to create an arraylist of multidimension arrays. Currently I've
managed to do these via conventional means as follows:

Dim myarraylist As ArrayList = New ArrayList()

Dim array1(,) As String = {{"bill"}, {"jill"}}

Dim array2(,) As String = {{"bob"}, {"jan"}}

myarraylist.Add(array1)

myarraylist.Add(array2)

However, I'd like to avoid having to declare each array, and assign the data
straight to the arraylist. Something like the following:

Dim myarraylist As ArrayList = New ArrayList()

myarraylist.Add({{"bill"}}, "jill"}})

myarraylist.Add({{"bob"}, {"jan"}})

Obviously, this example does not work, but does anyone know if I can
actually do it this way, or do I have to declare and initialise the arrays
first?

Thanks
 
A

Armin Zingler

Rob said:
Hi,

I want to create an arraylist of multidimension arrays. Currently
I've managed to do these via conventional means as follows:

Dim myarraylist As ArrayList = New ArrayList()

Dim array1(,) As String = {{"bill"}, {"jill"}}

Dim array2(,) As String = {{"bob"}, {"jan"}}

myarraylist.Add(array1)

myarraylist.Add(array2)

However, I'd like to avoid having to declare each array, and assign
the data straight to the arraylist. Something like the following:

Dim myarraylist As ArrayList = New ArrayList()

myarraylist.Add({{"bill"}}, "jill"}})

myarraylist.Add({{"bob"}, {"jan"}})

Obviously, this example does not work, but does anyone know if I can
actually do it this way, or do I have to declare and initialise the
arrays first?

myarraylist.Add(New String(,) {{"bill"}, {"jill"}})


Armin
 
R

Rob

Thanks for that. I thought I had tried that, but I must have got something
wrong at the time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top