.net 用反射 SetValue给实体类的属性赋值, 当属性定意为 int ?类型时,赋值时报错,显示转换失败
,请问怎么解决
之前赋值是直接这么写,总是报转换失败
prop.SetValue(entity,value, null);
t.SetValue(entity, 1);
//t PropertyInfo entity 操作的实体 1 int值
将赋值的值转为int?
你好,这是批量赋值的,值可能是字附型的,不能转换,有没有其它办法
@wanghongxing: 你这不是废话嘛..
类型都不对怎么赋值...你就不能转换一下再赋值吗
你好歹给点代码让大伙看看,不然怎么陪你讨论?
你properties来历不明,是否来自于T~