C# 类反射

通过给定的类名, 生成类的实例。

//Get the Type object for the ReflectTest.class
Type t = Type.GetType(“ReflectTest”)
//Get the parameterless constructor for the class
ConstructorInfo ctor = t.GetConstructor(System.Type.EmptyTypes);
//Invoke the constructor with a ‘null’ parameter
ReflectTest test = (ReflectTest) ctor.Invoke(null);