Sam*_*tar 3 c# switch-statement c#-8.0
这是我现在正在做的一个例子:
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.";
Run Code Online (Sandbox Code Playgroud)
代码字但不太了解添加到 switch 的内容 我想知道这是否也可以用 switch 表达式完成?
尝试这个
return shpc switch
{
0 => "Currently, based on your selection below, you have not yet identified any hidden cards in your card deck.",
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."
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
107 次 |
| 最近记录: |