Deep clone class and subclasses in C#

This question already has an answer here:

  • Deep cloning objects 39 answers

  • 使用这样的东西

    public object Clone()
    {
        using (var memStream = new MemoryStream())
        {
            var binaryFormatter = new BinaryFormatter(
               null, 
               new StreamingContext(StreamingContextStates.Clone));
            binaryFormatter.Serialize(memStream, this);
            memStream.Seek(0, SeekOrigin.Begin);
            return binaryFormatter.Deserialize(memStream);
        }
    }
    
    链接地址: http://www.djcxy.com/p/40762.html

    上一篇: 克隆参考类型

    下一篇: C#中的深克隆类和子类