DeepClone 或许对你很有用

 public static object Clone(object obj)
        {
            return Clone(obj, true);
        }

        public static object Clone(object obj, bool serialize)
        {
            MemoryStream ms = new MemoryStream();

            if (serialize)
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, obj);
                ms.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                return bf.Deserialize(ms);
            }
            else
            {
                ms.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                return ms;
            }
        }

你可能感兴趣的:(clone)