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() ?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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. |
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |