Copying an array

  • Thread starter Thread starter Tony Vitonis
  • Start date Start date
T

Tony Vitonis

I want to create a copy of a String array. Is this the best way to do
it?

CopyOfArray = CType(Array.CreateInstance(GetType(String), _
UBound(OriginalArray) + 1), String())

OriginalArray.CopyTo(CopyOfArray, 0)

Thanks.
 
it's great...but, you could make it more flexible by using the .gettype of
the originalarray when you do your ctype...that way, you should be able to
create/copy arrays of other types as well.

hth,

steve


| I want to create a copy of a String array. Is this the best way to do
| it?
|
| CopyOfArray = CType(Array.CreateInstance(GetType(String), _
| UBound(OriginalArray) + 1), String())
|
| OriginalArray.CopyTo(CopyOfArray, 0)
|
| Thanks.
 
Back
Top