首页 > 代码库 > Try Catch Finally working steps

Try Catch Finally working steps

 1 private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) 2         { 3             if (comboBox1.SelectedItem != null) 4             { 5                 MessageBox.Show(((DataRowView)comboBox1.SelectedItem)["Name"] + "  = " + ((DataRowView)comboBox1.SelectedItem)["Value"]); 6             } 7  8             try 9             {10                 int i = 1;11                 int k = 0;12 13                 int r = i / k;14 15             }16             catch (Exception ex)17             {18 19                 throw (ex);20                 //return;21             }22 23             //MessageBox.Show("After Exception continue..."); //if no finally, it is ok. with finally syntax error.24 25             finally26             {27                 MessageBox.Show("After Exception Finally...");28 29             }30 31             MessageBox.Show(".....After Exception continue...");32         }
View Code