Andrew Werber
asked on
Looping through properties of an object and changing the value of the properties
I want to loop through the properties of an object and replace a value in a string. The properties are all string types and I want to replace any < characters with <
I found some code at https://www.pluralsight.com/guides/microsoft-net/property-copying-between-two-objects-using-reflection that looks helpful, but I cannot figure out how to change the value of a property in the parent object before it's assigned to the child object.
The line in question is childProperty.SetValue(chi ld, parentProperty.GetValue(pa rent)); I want to be able to to the replacement above to parentProperty.GetValue(pa rent).
I found some code at https://www.pluralsight.com/guides/microsoft-net/property-copying-between-two-objects-using-reflection that looks helpful, but I cannot figure out how to change the value of a property in the parent object before it's assigned to the child object.
The line in question is childProperty.SetValue(chi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.