Converting ArrayList to String Array

  • Thread starter Thread starter Walter Zydhek
  • Start date Start date
W

Walter Zydhek

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(byval strChange() as string) as string()
Dim aryValue As ArrayList = New ArrayList(strChange)
aryValue.add "newvalue"

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

-Walt Zydhek
 
Walter Zydhek said:
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(byval strChange() as string) as string()
Dim aryValue As ArrayList = New ArrayList(strChange)
aryValue.add "newvalue"

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

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