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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top