Converting ArrayList to String Array

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

    Converting ArrayList to String Array

    Is it possible to convert an ArrayList to a string array?

    I have a routine that takes a string array as a parameter,
    converts it to an ArrayList for manipulation purposes,
    and now I need to convert it back to a string array.

    example of code I am using:

    Sub MakeChanges(byv al strChange() as string) as string()
    Dim aryValue As ArrayList = New ArrayList(strCh ange)
    aryValue.add "newvalue"

    ' here I want to convert the aryValue back to a string()
    End Sub

    -Walt Zydhek
  • Jon Skeet [C# MVP]

    #2
    Re: Converting ArrayList to String Array

    Walter Zydhek <walt@giftmarke t.org> wrote:[color=blue]
    > Is it possible to convert an ArrayList to a string array?
    >
    > I have a routine that takes a string array as a parameter,
    > converts it to an ArrayList for manipulation purposes,
    > and now I need to convert it back to a string array.
    >
    > example of code I am using:
    >
    > Sub MakeChanges(byv al strChange() as string) as string()
    > Dim aryValue As ArrayList = New ArrayList(strCh ange)
    > aryValue.add "newvalue"
    >
    > ' here I want to convert the aryValue back to a string()
    > End Sub[/color]

    Yes - look at ArrayList.ToArr ay (Type). You'll need to cast the
    reference returned to a string array.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...