How to load a class from class name?

slownet

Newcomer
Joined
May 30, 2003
Messages
10
Location
VA, USA
Hi,

I defined several classes in a namespace. I want to dynamically load a class using class name. In Java, I can use Class.ForName() function. How can I do that in C#?

Thanks in advance!
 
You have to use reflection.

C#:
Type t = typeof("full.class.name");
object o = Activator.CreateInstance(t);
 
Back
Top