.Net 反射牛刀小试

1. 根据类型实例化对象

//Type tp;

object o = Activator.CreateInstance(tp);

view = o as View;

 

2.根据类名称的字符串实例化对象

//Type tp;

Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();

object o3 = asm.CreateInstance(tp.ToString());

view = o3 as View;

 

原文地址:https://www.cnblogs.com/quietwalk/p/2567694.html