of course, it would help if I mentioned how to use
Activator.CreateInstance...
in this case, a simple
object o = Activator.CreateInstance(type);
should create an instance of your type, assuming no strange circumstances.
"Daniel O'Connell" <on******@comcast.net> wrote in message
news:Sk******************@rwcrnsc51.ops.asp.att.ne t...
"Marco" <a@b.c> wrote in message
news:1f****************************@phx.gbl... Howdy!
Given that:
Type type = Type.GetType("System.Windows.Forms.Button");
Question: How do I obtain a Button object by only knowing
the type object. In other words, how do I fire the
constructor of a type object (Button(), in this case) ???
Thank you and God bless.
Basically:
ConstructorInfo i = type.GetConstructor(Type.EmptyTypes);
object o = i.Invoke(null);
o should contain the object created by the constructor. Other methods
exist, of course, including Activator.CreateInstance(), which are probably eaiser
to use unless you need to verify a certain constructor exists. _____
Marco