How to instansiate objects dynamically?

thomas10001

Regular
Joined
Jun 22, 2003
Messages
57
Location
Samoa & Sweden
Is there possible to do something like this to instansiate objects dynamically?

Say I have a class

MyClass with constructor MyClass()

It could be an unlimited different classes I want to create so just doing a simple switch case would not work.

I would like to instansiate MyClass with say just only knowing the name of the class as a string, classString = "MyClass";
or providing any other information in order to create the class

Is there a way to make a method which instansiate the object

public Object createClass(classString)
{
// code to create the class, How to do that???
}

The reason is becasue this createClass will be in a base class which will not know what class types are able to create.
 
Back
Top