I'm currently using reflection in a project and got stuck in a tricky problem.
Seem's like i can't get the value of a nullable property of Datetime Type.
I'm currently running trough all the propertys of a class, and using getvalue() to assemble that. However specifically for Datetime?, the method always return null, even when value is passed. I'm getting value for int? using the current method.
Here's is my code.
Private Class1 compareObj(object obj1, object obj2)
{
Class1 return = new Class1();
var type = obj1.GetType();
PropertyInfo[] props = type.GetProperties();
foreach (PropertyInfo prop in props)
{
var val1 = prop.GetValue(obj1,null);
var val2 = prop.GetValue(obj2,null);
}
}
Aucun commentaire:
Enregistrer un commentaire