【发布时间】:2011-11-02 15:04:09
【问题描述】:
我想检查会话是否为空或为空,例如:
if(Session["emp_num"] != null)
{
if (!string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
//The code
}
}
或者只是
if(Session["emp_num"] != null)
{
// The code
}
因为有时我只检查:
if (!string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
//The code
}
我遇到以下异常:
空引用异常
【问题讨论】:
标签: c# asp.net session nullreferenceexception tostring