Hi i have a Number of Properties and My properties like
public XYZ()
{
xyz = new xyz1();
xyz2 = new xyz2();
}
public xyz1 xyz1 { get; set; }
public xyz2 xyz2 { get; set; }
}
public class xyz1
{
public string fName { get; set; }
public string lnameget; set;}
}
public class xyz2
{
public string city { get; set; }
public string state
}
While i am setting my property on runtime i am getting exception object reference set to null.
XYZ model = new XYZ();
PropertyInfo propertyInfo = model.GetType().GetProperty("fName");
propertyInfo.SetValue(model, Convert.ChangeType(item.InnerText, propertyInfo.PropertyType), null);
Please help me
Aucun commentaire:
Enregistrer un commentaire