System.Array.CopyTo( ) Vs System.Array.Clone( )

Started by VelMurugan, Feb 13, 2009, 08:56 AM

Previous topic - Next topic

VelMurugan

System.Array.CopyTo( ) Vs System.Array.Clone( )

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.

Source : csharpthegreat

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview