单挑这个程序很奇怪 - 编译错误?

时间:2018-06-15 12:55:21

标签: c# visual-studio visual-studio-2017 visual-studio-debugging

如果你在VS2017中单步执行这个微小的控制台程序,你最终会执行 WriteLine(...)语句 throw(...)语句。

这应该绝对不可能,那怎么可能是???

using System;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
           Task.Run(() => ProcAsync()).Wait();
        }


        private static async Task ProcAsync()
        {
            int aNumber = 7;

            switch (aNumber)
            {
                case 7:
                    Console.WriteLine("The value is 7");  //You first arrive here...
                    break;
                default:
                    throw new Exception("Oups..?!"); //but then also here!!!??
            }
        }

    }
}

0 个答案:

没有答案