小总结:用反射机制创建的分配数据分配器
public MUser DataAssigner(DataTable dt, MUser user) { foreach (DataRow dr in dt.Rows) { int i = 0; foreach (DataColumn dc in dr.Table.Columns) { PropertyInfo pi = user.GetType().GetProperty(dc.ColumnName); pi.SetValue(user, dc.Table.Rows[0][i], null); i++; } } return user; }