• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 42
  • Last Modified:

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).
Andrew Werber
Andrew Werber
1 Solution
Andrew WerberAuthor Commented:
I solved my problem. I had to (I guess) create a method to change the values in another class. So, I'm closing this.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now