C#根据类名称创建类的实例

转:http://blog.csdn.net/ise_keven1/article/details/2070049

方案一:

  using   System;    
  using   System.Reflection;     

  Type   type   =   Type.GetType("abc");  
  Activator.CreateInstance(type);

方案二:

  using   System;    
  using   System.Reflection;    
   
   
  Assembly   assem   =   Assembly.Load("dll名称");    
  Type   helloType   =   assem.GetType("类名");      
  Object   obj   =   Activator.CreateInstance(helloType);  

posted @ 2014-08-18 16:33  iLocationStudio  阅读(252)  评论(0编辑  收藏  举报