Copy members of a Parent object to a Child object
Wondering if there is a easy way in C# that provides copying members of a parent to a child without explicitly coding the copy of each members? This is what I would like to do...
public class Person
{
int age = 0;
}
public class Manager
{
}
class Test
{
[STAThread]
static void Main(string[] args)
{
Person p = new Person();
Manager m = new Manager();
p.age = 30;
// I know this will not work... but what I wanted to do is to copy the common
// denomiated members from parent to child... is there a way without coding
// copying of each members?
m = p;
}
}
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

bilnaadRank #2,169 · 655 pointsPosted Dec 15, 2004, 10:19 AM EST