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

C#能否象JAVA那样根据类名建立Class类型的对象

2013年03月14日 ⁄ 综合 ⁄ 共 299字 ⁄ 字号 评论关闭

http://community.csdn.net/Expert/topic/3214/3214785.xml?temp=.3455316

Activator.CreateInstance(ClassName)

问:自己定义的类也可以吗?
请问如何获取这个对象的引用??

Assembly a=Assembly.LoadFrom("employee.dll");
Type t=a.GetType("Company.Employee");
MethodInfo getsalary=t.GetMethod("DisplayMsg");
object obj=Activator.CreateInstance(t);
...

抱歉!评论已关闭.