473,804 Members | 3,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 27724
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.Co py 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.Len gth - 1) As String
astr1.CopyTo(as tr2, 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.B lockCopy, 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
1867
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 doing it correctly. Any idea what I'm doing wrong? Thx and Regards, Nicolas import array as arr
2
2060
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, array_type = "B"): array.array(array_type)
0
2840
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 decode. I have done a conversion to pyrex and have gotten it down to about 2 seconds to run both encode and decode. An an excerpt from the pyrex code is included below. My question is, is there a better way to allocate the memory for the...
2
2726
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 in the byte array gets copied to 1 element in the Int16 array. In VB6, this was easily done using CopyMemory. I need something in .NET that works as fast as CopyMemory. I
2
1482
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) pickleable but not unpickleable -- see below. I appreciate that arrays are inherently not pickleable because of the type code. However: (1) Anyone know why/when the world changed? (2) If we had alternative constructors like...
15
3829
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). Regardless of whether the array consists of POD's, we could use a loop such as: #include <cassert>
2
7049
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) or die "File cannot be copied.";
6
72912
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 copy those bytes to array2 on position from 15 to 65. How to do this? There are should be some function which work like "copy" function in C++.
5
3626
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 |--------|------------------------| | | | | | | | | | N
1
2307
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 40. Returning a Python list makes no sense. In Python I always work with the array.array module which does the trick. But now that I wrote my own C++ module for some preprocessing I need the return array.array objects.
0
9582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.