Object instance by class name

  • Thread starter Thread starter Ondrej Sevecek
  • Start date Start date
O

Ondrej Sevecek

Hello,
how to create an instance of some object class by using the class's name?
For example, I want to fulfill this pseudocode:

class MyNewClass
{
....
}

Object NewInstanceOfClass = new CreateTheObjectByClassName("MyNewClass");


Many thanks in advance
Ondra.
 
Lots of ways.

1) You can use the Activator class.
2) Or the Assembly.CreateInstance method.

There are probably other ways but these are all I can think of off the top
of my head.
 
Back
Top