C#C
C#17mo ago
hugi

child/parent class, how do i 'mass define' child properties?

So I have a class
public class Parent: child {
public IEnumerable<AdditionalProp> MoreStuff { get; set; }
}
public child {
public int age { get; set; }
public string name{ get; set; }
public int score{ get; set; }
.... (many more)
}

something like that...
so if I have a value of
Child a = data.getChild();
IEnumerable<AdditionalProp> b = data.getMoreStuff();
how do I make it so that I can put both into the Parent class without retrieving and setting the child variables (age, name etc.) separately?

(without Automapper)
Was this page helpful?