How to dynamically instantiate a class based on a string being the class name?
You can do it using reflection-
Reflection is the process by which a program can read its own metadata. A program is said to reflect on itself, extracting metadata from its assembly and using that metadata either to inform the user or to modify its own behavior.
You can invoke the Cos() of the System.Math class by first getting the Type information for the System.Math class:
Type mathType = Type.GetType("System.Math");
With that type information, you can dynamically load an instance of that class by using a static method of the Activator class.
The Activator class contains four methods, all static, which you can use to create objects locally or remotely or to obtain references to existing objects. One of them is CreateInstance:
Object theObj = Activator.CreateInstance(mathType);
Index