finally 블록은 프로그램이 실행되는 동안 항상 실행됩니다. 그러나,이 콘솔 응용 프로그램에서 finally 블록이 실행되지 않는 것 같습니다.왜 마침내 처형되지 않습니까?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
throw new Exception();
}
finally
{
Console.WriteLine("finally");
}
}
}
}
는 출력
참고 : 예외가 발생되었을 때 나는 appliation을 종료하고 싶다면, 윈도우 나를 askmed, 나는 '예.'고 말했다
클릭'no'를 제공하고 명령 줄에서 대신 그것은 매우 이상하게 보일 것 당신의 IDE –
실행 그것을 어떻게되는지. 'finally'는 StackTrace 다음에 정확히 써야합니다. – KevinDTimm
내 –