using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace Common { public class EntityBase { public M format(T t,M m) { PropertyInfo[] PropertyInfos1 = t.GetType().GetProperties(); PropertyInfo[] PropertyInfos2 = m.GetType().GetProperties(); object value; foreach (PropertyInfo p2 in PropertyInfos2) { foreach (PropertyInfo p1 in PropertyInfos1) { if (p2.Name.ToUpper() == p1.Name.ToUpper()) { value = p1.GetValue(t, null); if (value != null) { p2.SetValue(m, value, null); } } } } return m; } } }