public IList
GetList
(DataTable table) { IList
list = new List
(); T t = default(T); PropertyInfo[] propertypes = null; string tempName = string.Empty; foreach (DataRow row in table.Rows) { t = Activator.CreateInstance
(); propertypes = t.GetType().GetProperties(); foreach (PropertyInfo pro in propertypes) { tempName = pro.Name; if (table.Columns.Contains(tempName)) { object value = row[tempName]; pro.SetValue(t, value, null); } } list.Add(t); } return list; }
反射的一些东西
最新推荐文章于 2024-04-29 22:32:38 发布