multidimensional arrays and array lists

  • Thread starter Thread starter Rob
  • Start date Start date
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
 
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
 
Thanks for that. I thought I had tried that, but I must have got something
wrong at the time.
 
Back
Top