试下C# 8.0 的switch表达式 (VS2019)

class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Console.WriteLine(TestSwitch("0371"));
            Console.WriteLine(TestSwitch("071"));
            Console.ReadKey();
        }

        public static string TestSwitch(string code) =>
            code switch
            {
                "0371" => "郑州",
                "0378" => "开封",
                "0379" => "洛阳",
                _ => "其他地区"
            };
    }
原文地址:https://www.cnblogs.com/dayang12525/p/12710799.html