c#中深拷贝不常用,但是需要的时候如果没有,实在是麻烦的很。今天聊天,中梁大神说他实现了一个,赶紧学习学习。废话少说,直接上代码。
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class CloneHelper
{
public static object Clone(object obj)
{
Type type = obj.GetType();
object clone_obj = System.Activator.CreateInstance(type);
Copy(clone_obj, obj, type);
return clone_obj;
}
public static void Copy<T>(