无法抛出异常
我使用的是vs2010,程序源代码如下,是课本上一个非常简单的抛出DivideByZeroException异常的程序……原本应该是在控制台窗口显示,最后还是弹出了错误窗口,请问究竟怎么回事呢?
“An unhandled exception of type 'System.Exception' occurred in ConsoleApplication2.exe
Additional information: 除法运算发生了错误~
Attempted to divide by zero.
”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static int division(int x, int y)
{
try
{
return (int)(x / y);
}
catch (DivideByZeroException ex) { throw new Exception("除法运算发生了错误~" + Environment.NewLine + ex.Message); }
catch (Exception ex) { throw new Exception("除法运算发生了错误!!!!!!"); }
}
static void Main(string[] args)
{
int i = division(100, 0);
Console.ReadLine();
}
}
}
恳求众高手回答~谢谢!