I would like to iterate through a list of classes that extend class "A" and create objects of the extended classes' type.
Is there a way to replace the className in "new className();" with a variable or do I have to use a switch statement to create objects of different types?
List <A> listOfSubClasses; //A list of classes that all extend "A"
List <A> objects; //List to hold created objects
int[] variable;
foreach (A subClass in listOfSubClasses){
for (int i = 0; i < 3; i++){ //Let's say I want to create 3 objects of every class
objects.Add (new subClass()); //This is the line my question refers to
objects[objects.Count - 1].someParameter = variable[i];
}
}