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"; } } |
根据类名自动创建实例
最新推荐文章于 2021-03-02 01:13:19 发布