copy an object to another object but only with the same fields
Posted
by Coppermill
on Stack Overflow
See other posts from Stack Overflow
or by Coppermill
Published on 2010-04-06T19:52:08Z
Indexed on
2010/04/06
19:53 UTC
Read the original article
Hit count: 219
I would like to copy one object to another object, and the fields with the same names and type to be copied. Perhaps using reflections.
e.g.
object1.Name = object2.Name; object1.Age = object2.Age;
However if object2.Address is not in object1 then it would be ignored and vis-versa.
© Stack Overflow or respective owner