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"; } } |
根据类名自动创建实例
最新推荐文章于 2023-03-21 09:58:00 发布