Deep Copy in C#

后端 未结 8 635
独厮守ぢ
独厮守ぢ 2021-02-05 20:36

MSDN gives this example of a deep copy (http://msdn.microsoft.com/en-us/library/system.object.memberwiseclone.aspx)

public class Person 
{
    public int Age;
           


        
8条回答
  •  难免孤独
    2021-02-05 21:07

    The MemberwiseClone() creates a new instance of the class being copied, and also copies scalar fields into the corresponding members of the copy. It provides a better starting point for deep copying than just a plain new, because you need to "fix" only the items requiring deep copying.

提交回复
热议问题