how to create instance by type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

Is there any way to create an instance of a class using its type?
I mean something like this:

private void util() {
object a = null;

a = CreateObjectByType(typeof(MyClassA));
}

private object CreateObjectByType(Type classType) {
...
}

Thank you
 
Alex,

Yes, you want to take a look at the static CreateInstance method on the
Activator class.

Hope this helps.
 
Back
Top