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

来源:互联网 发布:淘宝美工提成方案 编辑:程序博客网 时间:2024/04/28 08:13

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);
...

原创粉丝点击