第一部分:
                 /// <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”对象?什么作用?

}
}

解决方案 »

  1.   

    session保存hashtable属性值
    Hashtable是用来表示一组组key/value结构的容器,其结构中Key用来快速查找,所以,叫它Dictionary可能更加合适。
      

  2.   

    1、Hashtable可以理解为由“键-值”对组成的元素的集合,可以通过键得到对应的值
    2、将值存储在Session变量,在整个应用程序中都可以使用,类似全局变量了
      

  3.   

    Hashtable 哈希表 键值配对。 Hashtable HsTest = new Hashtable();
                HsTest.Add(1, "A");
                HsTest.Add(2, "B");
                HsTest.Add(3, "B");            Response.Write(HsTest[1].ToString());//会输出A用Session来保存Hashtable Session["has"]=Hashtable ;