现在的位置: 首页 > 综合 > 正文

.Net 反射牛刀小试

2012年04月30日 ⁄ 综合 ⁄ 共 218字 ⁄ 字号 评论关闭

 

 

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;

 

抱歉!评论已关闭.