哪个代码最正确?
if (HttpContext.Current.Response.Cookies[authCookieName] != null) { HttpContext.Current.Response.Cookies[authCookieName].Value = "New Value"; }
要么
if (HttpContext.Current != null) if (HttpContext.Current.Response != null) if (HttpContext.Current.Response.Cookies != null) if (HttpContext.Current.Response.Cookies[authCookieName] != null) HttpContext.Current.Response.Cookies[authCookieName].Value = "New Value";
yfeldblum.. 19
如果HttpContext,HttpContext.Current,HttpContext.Current.Response或Http.Current.Response.Cookies中的任何一个为空,那么您已经遇到了麻烦.让异常发生并修复您的Web服务器.
如果HttpContext,HttpContext.Current,HttpContext.Current.Response或Http.Current.Response.Cookies中的任何一个为空,那么您已经遇到了麻烦.让异常发生并修复您的Web服务器.