【发布时间】:2018-03-28 21:53:48
【问题描述】:
我有以下代码:
public static class ItemsHelper
{
public static object product
{
get
{
return HttpContext.Current.Items["product"];
}
set
{
HttpContext.Current.Items["product"] = value;
}
}
}
然后,在一个函数中,我有以下表达式:
if (ItemsHelper.product is null) return false;
我在 Visual Studio 2017 中进行了测试,它工作正常,但我在两台运行 Visual Studio 2015 的不同计算机上进行了测试,它检索到以下错误:
预期类型)
有人知道为什么会这样吗?
【问题讨论】:
-
is null是 C# 7 的特性,当然在 VS 2015 中是没有的 -
你为什么不写
ItemsHelper.product == null? -
@Sentry 我可以,但我想了解为什么会这样
-
详解here.
标签: c# visual-studio-2015 visual-studio-2017 c#-7.0