Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • The example code I posted does not accurately represent my system in the sense that each class is unique in their usage and properties. Grouping them together using an interface or inheritance would not work in this instance. My apologies for the misunderstanding. Commented Oct 29, 2018 at 8:36
  • 1
    A base class won't work, but an interface might - given that you can add interfaces to any class that implement their signatures. It might still be possible to have a single Add function - you could potentially use reflection to find out what the object type is, look up an appropriate list in Zoo using reflection or maybe a dictionary, and then add the given object to the correct list. Commented Oct 29, 2018 at 8:46