C# Time of finally execution

后端 未结 9 1602
情话喂你
情话喂你 2021-02-04 01:37

Take this code:

using System;

namespace OddThrow
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
              


        
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 02:08

    The output is actually from the default CLR exception handler. Exception Handlers occur before the finally block. After the finally block the CLR terminates because of the unhandled exception (it can't terminate before, as c# guarantees [1] that the finally clause is called).

    So I'd say it's just standard behaviour, exception handling occurs before finally.

    [1] guranteed during normal operation at least in absence of internal runtime errors or power outage

提交回复
热议问题