简单的拷贝对象类
public static class TypeHelper { public static TP AutoCopy<TP, TC>(TC source) where TP : new() { TP dest = new TP(); var ParentType = typeof(TP); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(dest, Propertie.GetValue(source, null), null); } } return dest; } public static TP AutoCopy<TP, TC>(TP dest, TC source) where TP : new() { var ParentType = typeof(TP); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(dest, Propertie.GetValue(source, null), null); } } return dest; } }