how do i access string() array inside arraylist?

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

    #1

    how do i access string() array inside arraylist?

    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
  • Chris Dunaway

    #2
    Re: how do i access string() array inside arraylist?

    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(MyAr rayList(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 )

    Comment

    Working...