如果你在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!!!??
}
}
}
}