using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.Reflection; using System.Runtime.Remoting; using System.Drawing; using System.Windows.Forms; namespace GetConstructorTest { public class GooConsistency { public GooConsistency() { } } public class Monster { public Monster() { } } public class GooeyMonster: Monster { public GooeyMonster(GooConsistency gooness) { } } public class SqueltcheyMonster : Monster { public SqueltcheyMonster(Color tongueColor, bool isBackflipping) { } } public partial class Form1 : Form { public Form1() { object[] MonsterData1 = new object[] { new GooConsistency() }; Monster Monster1 = CreateMonster("GooeyMonster", MonsterData1); } public Monster CreateMonster(string type, Object[] vConstructorArgumentValues) { Type[] argtypes = Type.GetTypeArray(vConstructorArgumentValues); Type t = Type.GetType(type); ConstructorInfo info = t.GetConstructor(argtypes); return info.Invoke(vConstructorArgumentValues) as Monster; } } }