110,537
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Test1 test = new Test1();
foreach (var item in test.GetType().GetMethods())
{
try
{
item.Invoke(test, null);
}
catch (Exception)
{
MessageBox.Show("捕获异常");
}
}
}
public class Test1
{
public void method1()
{
throw new Exception("有异常");
}
public void method2()
{
throw new NotImplementedException();
}
}
}