ā How to add a list of type of another class in c#?
I'm doing a program where I need to store the a list of the Person class in the class of People. A Person is defined by her name, and age...How do I store a list of Person inside the People class?
5 Replies
It seems more like you want a list of people, not necessarily a
People
class with a list
Anyway, you do that like you do with any other property
You could initialize a List<Person> with static method
Then you could add person to that list in ctor
but its hacky
Factory functions are a very valid pattern. Or do you mean something else?
Everything is a valid pattern if it works
š
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.