473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

copy array to array

Jan
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
Nov 20 '05 #1
7 27697
In article <1l******************************@40tude.net>, 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
Nov 20 '05 #2
Jan <ca*****@planet.nl> 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>
Nov 20 '05 #3
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>
Nov 20 '05 #4
Cor
Hi Herfried,
I forgot to mention that you can use 'Array.Copy' for copying an array

too.
Is it better or "use too"?
:-))
Cor
Nov 20 '05 #5
* "Cor" <no*@non.com> 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>
Nov 20 '05 #6
Cor
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
Nov 20 '05 #7
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]" <hi***************@gmx.at> wrote in message
news:bm************@ID-208219.news.uni-berlin.de...
* "Cor" <no*@non.com> 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>

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nicolas Fleury | last post by:
Hi, Does anyone know if arrays would be picklable in python 2.4? Until then, I tried to derive from array.array and add __setstate__ and __getstate__ with the following code, but it seems I'm not...
2
by: Gus Tabares | last post by:
Hello all, I'm trying to subclass array.array but having problems with a default parameter in the init constructor. Example: import array class TestClass(array.array): def __init__(self,...
0
by: Chris Lambacher | last post by:
Hi, I have to do some data manipulation that needs to be fast. I had a generator approach (that was faster than a list approch) which was taking approximately 5 seconds to run both encode and...
2
by: TDH | last post by:
Hi, I need to do a raw copy of a byte array to an Int16 array. For e.g., I have an byte array which has length 100, and I need to copy this to an Int16 array that has length 50. So 2 elements...
2
by: John Machin | last post by:
Googling for "pickle array" in comp.lang.python yields old messages that show a PickleError -- plus one message where Alex Martelli writes "I am but an egg" :O) Looks like arrays are NOW (2.4.1)...
15
by: Frederick Gotham | last post by:
What's the canonical way to copy an array in C++? If we're copying a POD, we can use memcpy (but there could be a more efficient alternative if we know that the blocks are suitably aligned). ...
2
by: susinthaa | last post by:
Hi, How to copy an array to a file? I tried the File :: copy, But the array is not copying to the file. @susi=$telnet->cmd("logtail"); $newfile = "$movie/$song/$file"; copy(@susi,$newfile)...
6
by: =?Utf-8?B?U3VzaGlTZWFu?= | last post by:
Hello. How I can copy one byte array to other byte array? For example I have byte array1 = new byte; byte array2 = new byte; in array1 I have useful data from position 55 to 105 and I need...
5
by: VijaKhara | last post by:
Hi all, I have a 2-D array with the size M x N. Now I need to segment this array into two parts with sizes P x N and (M-P) x N. P | M-P |--------|------------------------| | ...
1
by: Fabio | last post by:
Hi All, I have a question concerning the use of array.array inside of C++ code I wrote. I am working with _big_ data files but some entries in these files are usually bounded say between -5 to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.