Dynamic instantiation of a class

  • Thread starter Thread starter Daniel Klein
  • Start date Start date
D

Daniel Klein

I'm looking for the VB.NET equivalent of the following java code:

toyName = "Barbie";
Class c = Class.forName(toyName);
Toy myToy = (Toy) c.newInstance();

A Google search has proved fruitless so far. I'm currently checking
out MSDN but it's a loooong, slooooow, process.

Thanks,
Daniel Klein
 
Hi Daniel, You should be looking at the Activator.CreateInstance method, in
System.Reflection.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 

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