Im trying to make a method that creates a new object of a class, but I want to be able to make objects of many different classes, so making a method for each class won’t work for me. Is there any way I can pass in a class to a method, so that a new object can be created? All of my classes have the same constructor.
Share
Have you read about Abstract Factory pattern?
EDITED
BTW, I do not think that reflection is good way to make your architecture, if you have a lot of classes with the same constructor try to use useful patters like Factory or Builder instead of creating one method with reflection.