Prior I'd like to appologize for the long title but I didn't figure out a shorter version.
I have an abstract base class that delivers generic methods to access functions in test classes, that derive from my base class.
I have a collection of classes that itself have a reference to those test classes.
The struct is:
// A really simplified example for my manager
Collection<AbstractBaseClass> Manager = new Collection<AbstractBaseClass>
{
TestClassA();
TestClassB();
}
Now I come to the point that I need to kill and recreate the instance in the collection of the testclass without knowledge of which testclass is in this collection.
I try to do sth. like (pseudocode)
Manager[0] = null;
Manager[0] = new (object)Manager[0].GetType();
I already stumbled over Get a new object instance from a Type but this - however - doesn't work because CreateInstance is no member of System.Activator. Also I cannot find the ObjectType class.
Long explaination, short question: How can I create a new instance from a class where I only have an Instance?
Thank you very much, ADP.
Aucun commentaire:
Enregistrer un commentaire