【发布时间】:2014-02-07 16:43:52
【问题描述】:
我的域类中有一个十进制值属性:
public class Domain
{
public decimal Value {get;set}
}
我需要为该 Value 属性分配两个数据库值:
obj1.Value = decimal.Parse(reader["Value"].ToString());
obj2.Value = decimal.Parse(reader["Value2"].ToString());
然后我有一个比较器方法来比较这两个属性:
public void Compare(List<object> Domains)
{
//get properties with reflection
//if the properties values are different I need to set a 'string' value [DIFFERENT] to it.
prop.SetValue(comparableObj, "[DIFFERENT]", null);
}
可以吗?
【问题讨论】:
-
这与类型安全语言完全相反。你不能那样做。
标签: c# .net reflection