By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,032 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,032 IT Pros & Developers. It's quick & easy.

copy array

P: n/a
Hi,
I have an array in a class
When I make a copy of that class and copy the array from one class to the
other the two arrays point to the same object:
arr=arr => same object
arr(0)=arr(0) ==> different objects
How do I copy an array without copying all the arrayelements one by one?
Thanks
Frank
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Frank,

You like this solution:

Array.Copy(arrSource, arrDest, arrSource.Length)

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight

"Frank" <fr***@frank.com> wrote in message
news:cj**********@news1.zwoll1.ov.home.nl...
Hi,
I have an array in a class
When I make a copy of that class and copy the array from one class to the
other the two arrays point to the same object:
arr=arr => same object
arr(0)=arr(0) ==> different objects
How do I copy an array without copying all the arrayelements one by one?
Thanks
Frank

Nov 21 '05 #2

P: n/a
thanks for the fast reaction Ken, it's too easy.
Frank

"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:#G**************@TK2MSFTNGP10.phx.gbl...
Hi Frank,

You like this solution:

Array.Copy(arrSource, arrDest, arrSource.Length)

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight

"Frank" <fr***@frank.com> wrote in message
news:cj**********@news1.zwoll1.ov.home.nl...
Hi,
I have an array in a class
When I make a copy of that class and copy the array from one class to the other the two arrays point to the same object:
arr=arr => same object
arr(0)=arr(0) ==> different objects
How do I copy an array without copying all the arrayelements one by one?
Thanks
Frank


Nov 21 '05 #3

P: n/a
Thats fine for a String type.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Frank" <fr***@frank.com> wrote in message
news:cj**********@news2.zwoll1.ov.home.nl...
thanks for the fast reaction Ken, it's too easy.
Frank

"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:#G**************@TK2MSFTNGP10.phx.gbl...
Hi Frank,

You like this solution:

Array.Copy(arrSource, arrDest, arrSource.Length)

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight

"Frank" <fr***@frank.com> wrote in message
news:cj**********@news1.zwoll1.ov.home.nl...
Hi,
I have an array in a class
When I make a copy of that class and copy the array from one class to the other the two arrays point to the same object:
arr=arr => same object
arr(0)=arr(0) ==> different objects
How do I copy an array without copying all the arrayelements one by one? Thanks
Frank



Nov 21 '05 #4

P: n/a
It seems to be working fine for my integer array
Frank
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
Thats fine for a String type.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Frank" <fr***@frank.com> wrote in message
news:cj**********@news2.zwoll1.ov.home.nl...
thanks for the fast reaction Ken, it's too easy.
Frank

"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:#G**************@TK2MSFTNGP10.phx.gbl...
Hi Frank,

You like this solution:

Array.Copy(arrSource, arrDest, arrSource.Length)

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight

"Frank" <fr***@frank.com> wrote in message
news:cj**********@news1.zwoll1.ov.home.nl...
> Hi,
> I have an array in a class
> When I make a copy of that class and copy the array from one class
to
the
> other the two arrays point to the same object:
> arr=arr => same object
> arr(0)=arr(0) ==> different objects
> How do I copy an array without copying all the arrayelements one by

one? > Thanks
> Frank
>
>



Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.