0

Thank you ahead of time.

Problem: I have x different class objects that contains y amount of different properties (y properties will rarely be the same among the x objects and nearly all properties will be strings). I need to be able to create a copy of the object that contains the same data (minus one property that will be changed later in the code) but the two object do not reference the same memory location.

Question:I am looking for a way to create a generic method that is able to copy the information from one object into another (or better yet return the copied object. I figure this may be possible with the use of reflections but I do not have any idea how to do this successfully. Is this possible?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MrBilly222
  • 65
  • 5
  • Do you have name of properties different in each class? try to give sample class structure. – Brijesh Feb 17 '17 at 04:04
  • While I believe you are looking for "deep clone" (and closed as duplicate of corresponding question) I very well could be wrong and you are asking for specific flavor using generics (based on tags) or something completely different altogether. Please [edit] your post to clarify if linked duplicate is not what you are after. – Alexei Levenkov Feb 17 '17 at 04:12
  • I was unaware it was called a deep clone. I think that will do what I am looking for! Thanks – MrBilly222 Feb 17 '17 at 04:23

0 Answers0