RSS Feed for This PostCurrent Article

How would one do a deep copy in .NET?

System.Array.CopyTo() - Deep copies an Array

Trackback URL

  1. 2 Comment(s)

  2. By Vignu on Mar 25, 2007 | Reply

    The First Approach.
    1.Create a new instance.
    2.Copy the properties from source instance to newly created instance.
    [Use reflection if you want to write a common method to achive this]

    The Second Approach.
    1. Serialize the object and deserialize the output.
    : Use binary serialization if you want private variables to be copied.
    : Use xml Serialization if you dont want private variable to be copied.

  3. By Abhishek on Mar 16, 2009 | Reply

    Two or more pointers have their own Data.
    class A
    {
    string c;
    }
    A a;
    B b;
    a=b;//deep copy

Post a Comment