jeudi 17 mars 2016

Cast to a type from the type name as a string

I have an existing base type and I would like to cast it to a derived type base upon the name of the type as a string, so something like this:

public void DoStuffInDerivedType(string derivedName) {
   (base as Type.GetType(derivedName)).DoThisThing();
}

I'm pretty sure this can't be done but would be good to know for sure. Thanks





Aucun commentaire:

Enregistrer un commentaire