Articles :: View

Convert string to Type in C#

You must have the full namespace in your string:

Type type = Type.GetType("Your.Namespace.Class"); //target type

object o = Activator.CreateInstance(type); // an instance of target type
IModule your = (IModule)o;
DefaultModule = your;


Comments

Add a comment!

    • #686 2017-08-01 10:28:41 reply
      ERES UN PUTO SUBNORMAL ESO NO FUNCIONA