Merging arrays

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Is there a way to merge two or more single dimension string arrays into a
single, single dimension string array?

Thanks

Regards
 
John said:
Hi

Is there a way to merge two or more single dimension string arrays into a
single, single dimension string array?

Thanks

Regards

There is no "merge" functionality but you could just append the arrays and
the sort the array in the "merged" order.

Hope this helps.

Lloyd Sheen
 
Or in addition to lloyd merge as it is forever done by looping through the
two ore more files.

Be aware to make it first arraylist in both situations otherwise it will
probably freeze up your computer.

Cor
 
John said:
Hi

Is there a way to merge two or more single dimension string arrays into a
single, single dimension string array?

Thanks

Regards

Create a new array with the combined size of the arrays, and copy the
elements from the arrays:

Dim newArray As String() = New String(oldArray1.Length + oldArray2.Length)
oldArray1.CopyTo(newArray, 0)
oldArray2.CopyTo(newArray, oldArray1.Length)
 
Create a new array with the combined size of the arrays, and copy the
elements from the arrays:

Dim newArray As String() = New String(oldArray1.Length + oldArray2.Length)

I'm sure you meant

.... New String(oldArray1.Length + oldArray2.Length - 1) {}


Mattias
 
Mattias said:
I'm sure you meant

... New String(oldArray1.Length + oldArray2.Length - 1) {}


Mattias

Yes. I don't program any VB myself nowadays. I thought that when
creating an array this way, it would use the size.
 
Back
Top