Link to home
Start Free TrialLog in
Avatar of Andrew Werber
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 &lt;

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(child, parentProperty.GetValue(parent)); I want to be able to to the replacement above to parentProperty.GetValue(parent).
ASKER CERTIFIED SOLUTION
Avatar of Andrew Werber
Andrew Werber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial