PC Review


Reply
Thread Tools Rate Thread

Merging arrays

 
 
John
Guest
Posts: n/a
 
      7th May 2007
Hi

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

Thanks

Regards


 
Reply With Quote
 
 
 
 
Lloyd Sheen
Guest
Posts: n/a
 
      7th May 2007

"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      7th May 2007
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Hi
>
> Is there a way to merge two or more single dimension string arrays into a
> single, single dimension string array?
>
> Thanks
>
> Regards
>
>



 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      7th May 2007
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
 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      7th May 2007
>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.
 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      8th May 2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrays of Multidimensional Arrays? barmy_mad@yahoo.co.uk Microsoft C# .NET 9 22nd Mar 2006 12:15 AM
Arrays of Multidimensional Arrays? barmy_mad@yahoo.co.uk Microsoft C# .NET 0 21st Mar 2006 09:09 PM
Arrays of Multidimensional Arrays? barmy_mad@yahoo.co.uk Microsoft C# .NET 0 21st Mar 2006 09:09 PM
arrays in arrays jacob Microsoft Excel Programming 4 29th Aug 2004 08:40 PM
Rectangular arrays Vs. multidimensional arrays. Nikhil Patel Microsoft C# .NET 2 21st Jul 2003 02:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:43 PM.