PC Review


Reply
Thread Tools Rate Thread

copy array to array

 
 
Jan
Guest
Posts: n/a
 
      8th Oct 2003
hi there,

How can i copy the entire content of an array in to another array?
I think for a pro user of vb.net it must be a easy question but not for a
starter like me

Thank you very much
 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      8th Oct 2003
In article <1le7x83mh6n9r$.s7qok8t86v0z$.(E-Mail Removed)>, Jan wrote:
> hi there,
>
> How can i copy the entire content of an array in to another array?
> I think for a pro user of vb.net it must be a easy question but not for a
> starter like me
>
> Thank you very much


Look at the System.Array.Copy method...

Tom Shelton
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Oct 2003
Jan <(E-Mail Removed)> scripsit:
> How can i copy the entire content of an array in to another array?


\\\
Dim astr1() As String = {"Hello", "World", "Bla"}
Dim astr2(astr1.Length - 1) As String
astr1.CopyTo(astr2, 0)
Dim s As String
For Each s In astr2
MsgBox(s)
Next s
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Oct 2003
I forgot to mention that you can use 'Array.Copy' for copying an array too.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      9th Oct 2003
Hi Herfried,
> I forgot to mention that you can use 'Array.Copy' for copying an array

too.
Is it better or "use too"?
:-))
Cor


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      9th Oct 2003
* "Cor" <(E-Mail Removed)> scripsit:
> > I forgot to mention that you can use 'Array.Copy' for copying an array
> > too.

>
> Is it better or "use too"?


It's an alternative.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      9th Oct 2003
Herfried,
You are right, I was looking at the for each loop and did not take time to
look well.
I was thinking you was copying it value by value.
:-)
Cor


 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      9th Oct 2003
Herfried,
Another alternative is System.Buffer.BlockCopy, especially if you are
dealing with Arrays of Primitive Types (Byte, Char, Short, Integer, Long,
Single, Double). Actually Buffer only works with arrays of Primitive Types.

Reading the help it sounds like Buffer performs better then the similar
methods in Array.

Hope this helps
Jay

"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:bm32c7$hqdnb$(E-Mail Removed)...
> * "Cor" <(E-Mail Removed)> scripsit:
> > > I forgot to mention that you can use 'Array.Copy' for copying an array
> > > too.

> >
> > Is it better or "use too"?

>
> It's an alternative.
>
> --
> Herfried K. Wagner
> MVP · VB Classic, VB.NET
> <http://www.mvps.org/dotnet>



 
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
Variant Array Copy, Array row contains Object Neal Zimm Microsoft Excel Programming 3 13th Apr 2010 03:21 PM
Fast copy method of sub array (=array range) possible? Thomas Lebrecht Microsoft VB .NET 0 19th Mar 2009 08:49 AM
Array.Copy and Cloning an array don't seem to work differently illegal.prime@gmail.com Microsoft Dot NET Framework 1 29th Aug 2006 12:13 AM
Array.Copy and Cloning an array don't seem to work differently illegal.prime@gmail.com Microsoft C# .NET 1 29th Aug 2006 12:13 AM
select variables ranges, copy to array, paste the array in new workbook Mathew Microsoft Excel Worksheet Functions 1 1st Apr 2005 09:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 AM.