IT Community - Software Programming, Web Development and Technical Support

What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?

This is a discussion on What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ? within the C# Programming forums, part of the Software Development category; What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-24-2007, 12:24 AM
Archer Archer is offline
D-Web Programmer
 
Join Date: Jun 2007
Posts: 52
Archer is on a distinguished road
Question What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?

What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 12:29 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: What’s the difference between the System.Array.CopyTo() and System.Array.Clone()

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.
The CopyTo() method copies the elements into another existing array.
Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.
A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-25-2007, 03:00 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: What’s the difference between the System.Array.CopyTo() and System.Array.Clone()

System.Array.CopyTo() method copies all the elements of the current one dimensional Array to the specified one dimensional Array.

System.Array.Clone method creates a shallow copy of the Array.

A shallow copy of Array copies only the element of the Array, whether they are referenced types or value types, but it does not copy the object that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to. In contrast the deep copy of an Array copies the elements and everything directly or indirectly referenced by the elements.

For more see below, Here a lot of discussion...

http://www.discussweb.com/c-programm....html#post8506
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!

Last edited by S.Vinothkumar : 08-25-2007 at 03:04 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the difference between "using System.Data;" and directly adding the refer KiruthikaSambandam ASP and ASP.NET Programming 1 11-15-2007 01:33 AM
Difference between System.String and System.StringBuilder class? S.Vinothkumar C# Programming 1 10-29-2007 05:23 AM
CopyTo and Clone nhoj C# Programming 4 08-17-2007 06:09 AM
What is the difference between "using System.Data;" and directly adding the reference H2o ASP and ASP.NET Programming 1 07-24-2007 03:33 AM
Difference between Array and ArrayList leoraja8 Java Programming 1 05-11-2007 04:06 AM


All times are GMT -7. The time now is 11:57 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0