标签:des blog ar for div log amp c new
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; } }
标签:des blog ar for div log amp c new
原文地址:http://www.cnblogs.com/garysun90/p/3956144.html