我在以下代码行收到一个错误:对象引用未设置为对象的实例。
if (Session["AutoCompleteCustomersPhone"] != null)
完整的代码块:
代码块如下:
if (Session["AutoCompleteCustomersPhone"] != null)
earchCustomerPhone = true;
else
{
searchCustomerPhone =
bool.Parse(Session["AutoCompleteCustomersPhone"].ToString());
}
在进行空值测试时,为什么会出现这个错误?
Session
本身就是null
。 - Daniel Hilgarth