multidimensional arrays and array lists

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    multidimensional arrays and array lists

    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

  • Armin Zingler

    #2
    Re: multidimensiona l arrays and array lists

    "Rob" <r_miller@ozema il.com.auschrie b
    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

    Comment

    • Rob

      #3
      Re: multidimensiona l arrays and array lists

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

      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:OWZNAs3zHH A.4916@TK2MSFTN GP03.phx.gbl...
      "Rob" <r_miller@ozema il.com.auschrie b
      >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.Ad d(array1)
      >>
      >myarraylist.Ad d(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.Ad d({{"bill"}}, "jill"}})
      >>
      >myarraylist.Ad d({{"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

      Comment

      Working...