我正在看这段代码:
public enum MO
{
Learn, Practice, Quiz
}
public enum CC
{
H
}
public class SomeSettings
{
public MO Mode { get; set; }
public CC Cc { get; set; }
}
static void Main(string[] args)
{
var Settings = new SomeSettings() { Cc = CC.H, Mode = MO.Practice };
var (msg,isCC,upd) = Settings.Mode switch {
case MO.Learn => ("Use this mode when you are first learning the phrases and their meanings.",
Settings.Cc == CC.H,
false),
case MO.Practice => ("Use this mode to help you memorize the phrases and their meanings.",
Settings.Cc == CC.H,
false),
case MO.Quiz => ("Use this mode to run a self marked test.",
Settings.Cc == CC.H,
true);
_ => default;
}
}
不幸的是,似乎msg
,isCC
和upd
没有正确声明,它给出了一条消息:
无法推断隐式类型解构变量“msg”的类型,对于 isCC 和 upd 也是如此。
你能帮我解释一下如何声明这些吗?