私はそのセッションを確認したい場合は、セッションをチェックすると、このようにいくつかのこと、すなわち、nullまたは空である:時々私はチェックインの際ため空かない
if(Session["emp_num"] != null)
{
if (!string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
//The code
}
}
それとも
if(Session["emp_num"] != null)
{
// The code
}
with:
if (!string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
//The code
}
私は以下に直面していますそれは、文字列が、他のいくつかの種類が格納されていない場合は
if (!string.IsNullOrEmpty(Session["emp_num"] as string))
{
//The code
}
:セッション変数emp_numは、文字列を格納する場合は、この
null参照の例外
は、この記事を見て http://stackoverflow.com/questions/234973/what-is-the-best-way-to-determine-a-session-variable-is-null -or-empty-in-c – Bobby
本当にうれしい、ありがとう。 –