第一种从构造函数创建对象
objecto=null;
System.Typet=System.Type.GetType(this.Type);
constructor=t.GetConstructor(newType[0]);//t.GetConstructor(Type.EmptyTypes)也可以
o=constructor.Invoke(null);
System.Typet=System.Type.GetType(this.Type);
constructor=t.GetConstructor(newType[0]);//t.GetConstructor(Type.EmptyTypes)也可以
o=constructor.Invoke(null);
第二种反射的静态方法
objecto=null;
System.Typet=System.Type.GetType(this.Type);
o=System.Activator.CreateInstance(t,true);
System.Typet=System.Type.GetType(this.Type);
o=System.Activator.CreateInstance(t,true);
Activator 是包含特定的方法,用以在本地或从远程创建对象类型,或获取对现有远程对象的引用。
这两种方法有什么区别呢?如有高人路过请给予指点