luckapple2

c#中常会涉及到一些类,List的深度拷贝。

 public object Clone(object ldc)
        {
            BinaryFormatter Formatter = new BinaryFormatter();
            MemoryStream stream = new MemoryStream();
            Formatter.Serialize(stream, ldc);
            stream.Position = 0;
            object clonedObj = Formatter.Deserialize(stream);
            stream.Close();
            return clonedObj;
        }

posted on 2011-06-02 11:07  luckapple2  阅读(1727)  评论(0编辑  收藏  举报

导航