Object's superfluous copy [msdn]

zhaozj2021-02-16  63

Object's shallow copy

Shallow Word Create a new instance with the original object with the same type, then copy the non-static field of the original object. If the field is a value type, the field performs a bitmap. If the field is a reference type, copy the reference but do not copy the referenced object; thus, the reference in the original object and the reference in the copy point to the same object. Instead, the entire contents of the object's deep copy copy objects are directly or indirectly referenced.

For example, if x is an Object with reference to object A and object B, and the object A also has a reference to the object M, the X-shallow copy is object Y, and Y has the object A and the object B Quote. In contrast, the deep copy of X is the object y, and the object Y has a direct reference to the object C and object D and an indirect reference to the object N, where C is a copy of A, and D is a copy of B, and N is a copy of M .

The Type of the replica is the same as the type of the original Object.

Object.memberwiseclone method [C #] Creates a shallow copy of the current Object.

转载请注明原文地址:https://www.9cbs.com/read-15839.html

New Post(0)