这是我现在正在做的一个示例:
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 表达式来完成?
最佳答案
试试这个
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."
};
关于c# - C# 8 新 switch 可以替换包含多个的代码块吗? : ? : expressions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59510149/