public string ReturnMethod(int x) { return x switch { 2 => "2", 3 => "3", _ => "default" //_ 代表switch中的default }; }
C#语法糖——持续更新
原文:https://www.cnblogs.com/boydenyol/p/12946029.html