I was wondering if it is possible to use Reflection or something else to call a constructor in a method by having the className passed as string to the method. This is done in the context of interpretation of commands. Trying to avoid switch statements (I have some weird assignments at school and I am looking for a shortcut for my exams).
Class SomeClass
{
//irrelevant code here
public BaseClass SomeMethod(string constructorName)
{
//call constructor here through string parameter to avoid switch statements
//for example string constructorName=SomeDerivedClassName
// and the result should be:
return SomeDerivedClassName(this.SomeProperty,this.SomeOtherPropertY);
}
}