Change property type using reflection-Collection of common programming errors
I have a decimal Value property in my domain class:
public class Domain
{
public decimal Value {get;set}
}
I need to assign that Value property with two database values:
obj1.Value = decimal.Parse(reader["Value"].ToString());
obj2.Value = decimal.Parse(reader["Value2"].ToString());
Than i have a comparer method wich compare these two properties:
public void Compare(List 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);
}
Is it possible to do?