【发布时间】:2020-04-05 07:16:40
【问题描述】:
这是我现在拥有的代码:
return cardChoice switch
{
var x when
x == CC.F1 ||
x == CC.F2 ||
x == CC.F3 ||
x == CC.F4 ||
x == CC.F5 => $"There are 0 cards in this collection.Add cards by tapping > of any card set then choose {cardChoice}.",
CC.H => "There are 0 cards in this collection. Add cards by tapping > of any card set then choose Hide.",
_ => throw new InvalidEnumArgumentException("Unhandled value: " + cardChoice.ToString()),
};
有没有办法进一步简化 x == .. 的检查?
【问题讨论】:
-
F1、F2等到底是什么,为什么它们不存储为数组或列表?
标签: c#