这是我之前多次注意到的行为,我想知道其背后的原因。如果您在 (Visual Studio 2008) 调试器下运行以下程序,throw
无论您多久继续调试,调试器都会不断中断语句。你必须停止调试才能离开那里。如果您在没有调试器的情况下运行程序,我希望调试器中断一次,然后进程终止。有人知道这种行为的充分理由吗?
using System;
namespace ExceptionTest
{
static internal class Program
{
static internal void Main()
{
try
{
throw new Exception();
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
// The debuger will never go beyond
// the throw statement and terminate
// the process. Why?
throw;
}
}
}
}