using System;public class Test5
{
private void func()
{
//1
try
{
//2
Console.WriteLine("2");
//3
throw new ApplicationException();
//4
Console.WriteLine("3");
}
catch (ApplicationException e)
{
//5
Console.WriteLine("5");
throw new Exception();
}
catch (Exception e)
{
//6
Console.WriteLine("6");
}
finally
{
//7
Console.WriteLine("7");
} //8
Console.WriteLine("8");
} public void test()
{
try
{
//9
func();
}
catch (Exception e)
{
//10
Console.WriteLine("10");
}
finally
{
//11
Console.WriteLine("11");
}
} static void Main(string[] args)
{
//12
(new Test5()).test();
}
}
为什么输出是
2
5
7
10
11
在//5处throw了为什么还会执行finally?
{
private void func()
{
//1
try
{
//2
Console.WriteLine("2");
//3
throw new ApplicationException();
//4
Console.WriteLine("3");
}
catch (ApplicationException e)
{
//5
Console.WriteLine("5");
throw new Exception();
}
catch (Exception e)
{
//6
Console.WriteLine("6");
}
finally
{
//7
Console.WriteLine("7");
} //8
Console.WriteLine("8");
} public void test()
{
try
{
//9
func();
}
catch (Exception e)
{
//10
Console.WriteLine("10");
}
finally
{
//11
Console.WriteLine("11");
}
} static void Main(string[] args)
{
//12
(new Test5()).test();
}
}
为什么输出是
2
5
7
10
11
在//5处throw了为什么还会执行finally?
解决方案 »
- 在线急求。。。解决了的话,马上结贴散分。。关于visual studio 2010的调试问题
- 如何在复合控件里编写repeater子控件的ItemTemplate和绑定数据?
- C# RichTextBox 控件(Windows 窗体)如何添加图片
- 老板崔!!用radiobutton这个控件做统计,有问题!!
- Front Page服务器扩展怎么安装啊?
- 大家帮忙!!!
- 怎樣把一個 內碼為unicode的文件轉換為gb2312文件.
- [谢谢]关于反射调用.dll文件中方法的疑问!!!
- 后台使用Convert.ToInt32后,把前台传来的值自动转为0了,求解?
- .net下合并两个项目(winform和web)
- C# ADSI高手帮帮我
- 怎么把datagrid的数据往excel导出啊??谢谢
{
//5
try
{
Console.WriteLine("5");
throw new Exception();
}
catch (Exception e)
{
Console.WriteLine("只有try才能捕获异常");
}
}
catch (Exception e)
{
//6
Console.WriteLine("6");
}
finally
{
//7
Console.WriteLine("7");
}