I didn't know that way but did know of
Dim Array(,) as Integer
Dim Array2(,) as Integer = Array.clone()
this assumes that you are not using OPTION STRICT. In that case
you would need to use the following:
Array2 = DirectCast(Array.clone(), Integer(,))
The need for all of this is that in VB.Net Arrays are now reference
based instead of value based. So directly copying with just "="
doesn't work but creates a pointer to the new array.
This isn't completely my own ideas did get the info from MS Press:
Programming Microsoft Visual Basic .NET by Francesco Balena, etal.
Great book, would recommend to all. Great information, great examples,
makes you think but shows you the details. At over 1300 pgs I hope
to get through it soon. The above information though is expalined in
chapter 2 on datatypes and variables.
Frank Clark
"SBS Rocks"
1/4/2005 11:50:46 AM
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in
message
<#S**************@tk2msftngp13.phx.gbl>
"Dave" <dave@4_rem_ove_scotts.com> schrieb: Is there an easier way to duplicate an array than copying each
element in a loop? If I just set one array equal to the other they end up
pointing to the same storage location and I can't manipulate one without
effecting the other.
'Array.Copy' (shared member), 'Array.CopyTo' (instance member).
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>