流浪のwolf

卷帝

导航

C# 新语法 switch 的简单写法

 // C# 中的新语法 switch 的简写
            string str = "123";
            string res = str switch
            {
                "1" => "1",
                "2" => "2",
                "3" => "3",
                _ => "default",
            };

 

posted on 2024-02-24 10:55  流浪のwolf  阅读(296)  评论(0编辑  收藏  举报