469,315 Members | 1,429 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

Merging arrays

Hi

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

Thanks

Regards
May 7 '07 #1
5 9971

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:eN**************@TK2MSFTNGP04.phx.gbl...
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

May 7 '07 #2
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" <Jo**@nospam.infovis.co.ukschreef in bericht
news:eN**************@TK2MSFTNGP04.phx.gbl...
Hi

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

Thanks

Regards


May 7 '07 #3
John wrote:
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)

--
Göran Andersson
_____
http://www.guffa.com
May 7 '07 #4
>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 Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 7 '07 #5
Mattias Sjögren wrote:
>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
Yes. I don't program any VB myself nowadays. I thought that when
creating an array this way, it would use the size.

--
Göran Andersson
_____
http://www.guffa.com
May 8 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tmenke | last post: by
4 posts views Thread by Bush will disarm all workers next | last post: by
3 posts views Thread by Patrick | last post: by
3 posts views Thread by André Hänsel | last post: by
8 posts views Thread by vidishasharma | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.