jeudi 4 juin 2015

How do you use reflection to get a sub property?

Let's see if I can explain what I'm trying to do...

Say I have an object, with a path to a property that looks like this:

Appointment.Person.Name

If I want to update the "Person" property, i could do something like this:

PropertyInfo subPropertyInfo = apptObject.GetType().GetProperty("Person");
subPropertyInfo.SetValue(apptObject, replacementValue, null);

But how would I update the Name Property for the root object?





Aucun commentaire:

Enregistrer un commentaire