第一部分:
/// <summary>
/// Gets the last time the forum was read.
/// </summary>
/// <param name="forumID">This is the ID of the forum you wish to get the last read date from.</param>
/// <returns>A DateTime object of when the forum was last read.</returns>
public DateTime GetForumRead( int forumID )
{
System.Collections.Hashtable t = Mession.ForumRead;
问题一:Hashtable有什么作用?看MSDN了,但是不懂啊?
if ( t == null || !t.ContainsKey( forumID ) )
return ( DateTime ) Mession.LastVisit;
else
return ( DateTime ) t [forumID];
}第二部分:
static public Hashtable ForumRead
{
get
{
if ( HttpContext.Current.Session ["forumread"] != null )
return ( Hashtable ) HttpContext.Current.Session ["forumread"];
else
return null;
}
set
{
HttpContext.Current.Session ["forumread"] = value;
问题二:在这里为什么使用“Session”对象?什么作用?
}
}
/// <summary>
/// Gets the last time the forum was read.
/// </summary>
/// <param name="forumID">This is the ID of the forum you wish to get the last read date from.</param>
/// <returns>A DateTime object of when the forum was last read.</returns>
public DateTime GetForumRead( int forumID )
{
System.Collections.Hashtable t = Mession.ForumRead;
问题一:Hashtable有什么作用?看MSDN了,但是不懂啊?
if ( t == null || !t.ContainsKey( forumID ) )
return ( DateTime ) Mession.LastVisit;
else
return ( DateTime ) t [forumID];
}第二部分:
static public Hashtable ForumRead
{
get
{
if ( HttpContext.Current.Session ["forumread"] != null )
return ( Hashtable ) HttpContext.Current.Session ["forumread"];
else
return null;
}
set
{
HttpContext.Current.Session ["forumread"] = value;
问题二:在这里为什么使用“Session”对象?什么作用?
}
}
解决方案 »
- 用GridView发布分类新闻如何提高效率?用一个GridView还是几个?
- 急……panel里面的文本框如何获得鼠标焦点??
- 十万火急,找不到类文件
- ibatis如何输出执行的sql语句到控制台
- 网站问题 急!!!!!!
- ---------求 windows身份验证的问题
- 求教:计算重复率的公式或算法
- 如何在动态设置内嵌框架(inframe)的高度,以及在其中显示所需页面
- 每次在定位框架的时候,总是浪费好多的时间.可有什么好的方面按百分比定位.
- 单选按扭(RADIOBUTTON)服务器控件单击反怎么没有触发服务器端的checkedchange事件啊?想单击它后在服务器端做事件处理怎么办??
- 关于tfs的使用
- ASP.NET的Repeater控件疑问
Hashtable是用来表示一组组key/value结构的容器,其结构中Key用来快速查找,所以,叫它Dictionary可能更加合适。
2、将值存储在Session变量,在整个应用程序中都可以使用,类似全局变量了
HsTest.Add(1, "A");
HsTest.Add(2, "B");
HsTest.Add(3, "B"); Response.Write(HsTest[1].ToString());//会输出A用Session来保存Hashtable Session["has"]=Hashtable ;