请问一个关于Session的问题

Tomato77 2005-10-19 02:17:54
请问
Session.Contents.Remove("abc");
Session["abc"]=null;
Session.Remove("abc");
有什么区别?

如果我想清空Session["abc"]的值,应该用哪个比较好?
...全文
103 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tomato77 2005-10-20
  • 打赏
  • 举报
回复
明白!谢谢!
saucer 2005-10-19
  • 打赏
  • 举报
回复
1.Session.Contents.Remove("abc");
2.Session["abc"]=null;
3.Session.Remove("abc");

1 is same as 3, both remove an entry called "abc"

2 is different, if the entry "abc" doesn't exist, it is created, then the value is set to null

果你的目的除去abc,用3,如果你的目的是把abc对应的值设置成null,用2

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧