private void button1_Click(object sender, EventArgs e)
{
try
{
string s = "";
int i = 1 / int.Parse(s);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
MessageBox.Show("Test");
}
}
先执行try块 > Catch的Exception 得到 EX > 执行Finally块 > 再到 throw new exception
本文通过一个具体的代码示例,详细解释了.NET框架中try-catch-finally结构的作用,展示了如何在代码中捕获异常并进行最终操作。
607

被折叠的 条评论
为什么被折叠?



