© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
7 replies
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)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

JSON convert child class defined as parent class
C#CC# / help
4y ago
How do I call the constructor of a parent class?
C#CC# / help
3y ago
How to activate Child Class?
C#CC# / help
13mo ago
❔ cast parent to child
C#CC# / help
4y ago