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
 
Back
Top