CSDN博客

img JAVAvNET

根据类名自动创建实例

发表于2004/11/3 11:00:00  822人阅读

  private void button1_Click(object sender, System.EventArgs e)
  {
   string LoadClassName = "LoadClass.Test";
   Type type = Type.GetType(LoadClassName, true );
   object newInstance = Activator.CreateInstance( type );
   MessageBox.Show(newInstance.ToString());
  }
 }
 public class Test
 {
  public Test(){}
  public string GetStr()
  {
   return "Test LoadClass.";
  }
  public override string ToString()
  {
   return "Test";
  }
 }
阅读全文
0 0

相关文章推荐

img
取 消
img