2
當我把SecondMain()
裏面的嘗試blcok secondMain()
內的最後一塊正在執行。但是當我把它放在外面的時候它並沒有執行。爲什麼它不執行?C#最後的塊沒有執行時,拋出異常拋出
static void Main(string[] args)
{
try
{
SecondMain(args); //try putting
Console.WriteLine("try 1");
throw new Exception("Just fail me");
}
finally
{
Console.WriteLine("finally");
}
}
static void SecondMain(string[] args)
{
try
{
throw new StackOverflowException();
}
catch (Exception)
{
Console.WriteLine("catch");
throw;
}
finally
{
Console.WriteLine("finally");
}
}