【发布时间】:2017-11-21 07:49:11
【问题描述】:
我想在 theme.VersionStamp 上插入另一个 null 检查。有没有办法可以将它插入到 SequenceEqual 参数中?
if (theme.VersionStamp != null)
{
if (!origTheme?.VersionStamp.SequenceEqual(theme.VersionStamp) ?? false)
{
throw new TwConcurrencyException();
}
}
【问题讨论】:
-
“我想在主题上插入另一个空检查” -- 为什么?当您到达那部分代码时,您已经知道该值不是
null。那里的空检查有什么意义?如果有一点,你想要什么样的空检查?你希望结果是什么?解决您的问题,使其包含一个好的minimal reproducible example,清楚地显示您在做什么,解释该代码的作用以及您希望它做什么,以及您不能做什么具体弄清楚。
标签: c# null-propagation-operator