问题描述
c#中下面三个代码行之间有什么区别?
他们是同一个
1.如果(Session ["DETAILS"] == null)
2. if(session ["Details"] ==")
3. if(Session ["DETAILS"].ToString()=="NEW")
What is the difference between three below code lines in c#?
Are they same
1. if (Session["DETAILS"] == null)
2. if(session["Details"] == "")
3. if(Session["DETAILS"].ToString() == "NEW")
推荐答案
if(Session["Name"] == null)
if(Session["Name"]=="")
if(Session["Name"].ToString()=="")
1.检查是否存在带有名称"的会话(是否已连接)
2.检查带有名称"的会话是否有数据
3.与2.相同.大多数情况下,会话中的数据在处理之前都会转换为字符串.
只需使用此代码段并尝试调试,您就可以很好地理解.
1.checks whether session with "Name" exists or not(crated or not)
2. checks if session with "Name" has data or not
3. Same as 2. Most often data in session is converted to string before dealing with it.
just use this snippet and try debugging, u can understand well.
这篇关于朋友您好,我在上课时遇到问题.我需要检查页面加载中的新会话.所以请告诉我解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!