试下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" => "洛阳", _ => "其他地区" }; }
一份耕耘,一份收获,付出就有回报永不遭遇过失败,因我所碰到的都是暂时的挫折