Thursday, May 04, 2006

Types of Cloning: Deep and Shallow

In this article, I shall talk about an interesting aspect of .NET programming - Cloning objects.

A lenyeg:

We can classify two types of cloning based on “how much” is cloned: Deep and Shallow. A shallow clone is a new instance of the same type as the original object, which contains a copy of the value typed fields. But, if the field is a reference type, the reference is copied, not the referred object. Hence, the reference in the original object and the reference in the clone point to the same object. A deep clone of an object, on the other hand, contains a copy of everything directly or indirectly referenced by the object.

Ez a System.Xml.XmlDocument ImportNode-janak deep parameterekent azt jelenti, hogy a az adott node childnodejait is masoljuk vagy azokat nem.