C#的异常处理是截断式的,一旦发生异常之后,直到被捕获,中间的代码是没有机会执行的。
1 private void Form1_Load(object sender, EventArgs e) 2 { 3 try { 4 test(); 5 MessageBox.Show("main"); 6 } 7 catch (Exception ex) 8 { 9 MessageBox.Show("form laod");10 }11 }12 13 private void test()14 {15 try16 {17 int i = 0;18 int b = 9 / i;19 }20 catch (Exception ex)21 {22 throw ex;23 }24 MessageBox.Show("test");25 }