【发布时间】:2020-02-25 22:57:00
【问题描述】:
我正在使用C# 7.0is type pattern。我正在尝试检查 object 是 not bool 还是 bool 值等于 false。但是,我目前使用 bool 类型的模式是:
if (obj is bool boolean && boolean)
{
/* I'm not doing anything here */
}
else
{
DoSomething();
}
有没有办法使用相同的类型模式反转这个if 表达式?
【问题讨论】:
标签: c#-7.0