【发布时间】:2019-12-28 10:42:58
【问题描述】:
这是我现在正在做的一个例子:
return
shpc == 0 ? "Currently, based on your selection below, you have not yet identified any hidden cards in your card deck." :
shpc == 1 ? "Currently, based on your selection below, you have one hidden card in your card deck." :
$"Currently, based on your selection below, you have {shpc} hidden cards in your card deck. These will not be visible.";
代码词,但对添加到 switch 的内容不太了解我想知道这是否也可以使用 switch 表达式来完成?
【问题讨论】:
-
你可以用“经典”开关替换它,不需要c#8开关的新奇特性
-
@GianPaolo switch 表达式比
switch语句更简洁,更易于使用,在 case 块中有很多returns 或直接变量赋值。
标签: c# switch-statement c#-8.0