1
static void Main(string[] args)
{
try
{
var intValue = "test";
var test = Convert.ToInt32(intValue);
}
catch (FormatException)
{
Console.WriteLine("format exception");
throw;
}
catch (Exception)
{
}
finally
{
Console.WriteLine("finally");
}
}
据我所知,在从字符串转换为int的过程中,引发了一个FormatException。现在在catch块中,我们重新抛出原始异常。为什么这不会被捕获到泛型异常catch块?如果我把try/catch放在throw上,那么应用程序不会崩溃。为什么这个C#代码会导致进程崩溃?