how do i access string() array inside arraylist?

G

Guest

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
 
C

Chris Dunaway

dotnetnoob said:
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)
 

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