c# - Dynamically creating objects at runtime that inherit from a base class -
i writing game editor, , have lot of different "tool" objects. inherit btool , have same constructor. i dynamically populate toolbox @ runtime buttons correspond these tools, , when clicked have them create instance of tool , set current tool. is possible, , if better/easier creating buttons hand? yes. to find tools, can call assembly.gettypes : var tooltypes = typeof(tool).assembly.gettypes() .where(t => typeof(tool).isassignablefrom(t)) .toarray(); to create tools, can call activator.createinstance : obj = activator.createinstance(type, arg1, arg2);