Assuming that the class has a public default constructor:
imports System.Reflection;
public void Init(Type sssType) {
ConstructorInfo constructor = sssType.GetConstructor(new Type[]{});
if(constructor != null) {
object myObject = constructor.Invoke(new object[]{});
// Use myObject
}
}
"rapataa" <dg@rapataa.frup> wrote in message
news:31**************************@msgid.xenosite.n et...
hi,
anyone knows how to instantiate a class, using only the type?
for example:
public void Init(Type sssType)
{
object = new sssType ?????
}
the method Init will be called like this:
Sustem.Typ sss = typeof(myClass);
Init(sss);