Home All Groups Group Topic Archive Search About

how do i access string() array inside arraylist?

Author
27 Jul 2006 7:10 PM
dotnetnoob
i have a arraylist that store String() array

the string array hold value 1 2 4

i want to access the string array that is inside the arraylist one arraylist
item at the time

i search up and down for a way to do this but i havn't come arcoss anything
that can help with this problem.

please help if you have done this before

thank

Author
27 Jul 2006 8:20 PM
Chris Dunaway
dotnetnoob wrote:
> i have a arraylist that store String() array
>
> the string array hold value 1 2 4
>
> i want to access the string array that is inside the arraylist one arraylist
> item at the time
>

Dim MyStringArray As String() = DirectCast(MyArrayList(2), String())
Dim sValue As String = MyStringArray(3)

This line gets the fourth string (0 based) from the string array that
is index 3 of the array list.  Since ArrayList only returns Object, you
must cast that object to an array of strings.

If you are using VS2005 or .Net 2.0, consider using the generic list
class:

Dim MyArrays As List(Of String())

'Code to populate the list here

Dim MyStringArray As String() = MyArrays(2)
Dim sValue As String = MyStringArray(3)