- Home /
How do i convert a String into a Class reference in C#
I have the String className and i want to convert it to a class reference. what function do i use? for example: new whateverFunction("Class1")(); would be the same as: new Class1();
Is this possible?
Comment
Answer by Mike 3 · Jan 12, 2011 at 06:13 PM
You would use the activator class:
System.Activator.CreateInstance(Type.GetType("Class1"));
Documented here: