c# 不同类同属性赋值
private D Mapper<D, S>(S s) { D d = Activator.CreateInstance<D>(); try { var sType = s.GetType(); var dType = typeof(D); foreach (PropertyInfo sP in sType.GetProperties()) { foreach (PropertyInfo dP in dType.GetProperties()) { if (dP.Name == sP.Name) { dP.SetValue(d, sP.GetValue(s)); break; } } } } catch (Exception ex) { } return d; }