我无法弄清楚为什么这不起作用。谁能向我解释为什么 SetValue 不设置我的对象属性的值?
T row = new T();
foreach (PropertyInfo property in row.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
{
Field[] dbFields = property.GetCustomAttributes(typeof(Field), false) as Field[];
Object obj = (Int32)1000; // Arbitrary Value;
Object castObj = Convert.ChangeType(obj, property.PropertyType);
property.SetValue(row, castObj, null); // DOES NOT UPDATE row!! WHY!?
}
任何帮助表示赞赏。