for (int i=0;i<=Session.Count-1;i++)
{
Response.Write(Session[i].ToString());
}

解决方案 »

  1.   

    Session["a"] = "a";
    Session["b"] = "b";for (int i=0;i<=Session.Count-1;i++)
    {
    Response.Write(Session[i].ToString());
    }
    It is ok!
      

  2.   

    foreach( DictionaryEntry item in Session )
    {
       object key = item.Key;  //获取键
       object value = item.Value;  //获取值
    }
      

  3.   

    这样比较精简点:for(int i=0;i<Session.Count;i++){.....}--------------------------------
    AspNetPager 免费分页控件4.1版发布,欢迎下载使用:http://www.webdiyer.com
      

  4.   

    DictionaryEntry 结构  [C#]请参见
    DictionaryEntry 成员 | System.Collections 命名空间 | IDictionary | IDictionaryEnumerator 
    要求
    命名空间: System.Collections平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family程序集: Mscorlib (在 Mscorlib.dll 中)
    语言
    C#C++JScriptVisual Basic全部显示
    定义可设置或检索的字典键值对。有关此类型所有成员的列表,请参阅 DictionaryEntry 成员。System.Object
       System.ValueType
          System.Collections.DictionaryEntry[Visual Basic]
    <Serializable>
    Public Structure DictionaryEntry
    [C#]
    [Serializable]
    public struct DictionaryEntry
    [C++]
    [Serializable]
    public __value struct DictionaryEntry
    [JScript] 在 JScript 中,可以使用 .NET 框架中的结构,但不能定义自己的结构。线程安全
    此类型的公共静态(在 Visual Basic 中为 Shared)成员对于多线程操作是安全的。不能保证实例成员是线程安全的。备注
    IDictionaryEnumerator.Entry 方法返回此类的实例。C# 语言中的 foreach 语句(在 Visual Basic 中为 for each)需要集合中每个元素的类型。由于基于 IDictionary 的集合中的每个元素都是键/值对,因此元素类型既不是键的类型也不是值的类型。而是 DictionaryEntry 类型。例如,foreach (DictionaryEntry myEntry in myHashtable) {...} 
      

  5.   

    1.How to Share Session State Between Classic ASP and ASP.NET
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/converttoaspnet.asp
    2. use hidden controlsTransfer Session Variables from Classic ASP to ASP.NET
    http://www.eggheadcafe.com/articles/20021207.asp
      

  6.   

    都讲完了那我还讲什么呀!?

    for (int i=0;i<=Session.Count-1;i++)
    {
    Response.Write(Session[i].ToString());
    }
    还是还可以很方便的遍历其它树组而不必知道数组中元素的类型。
      

  7.   

    public void GetSession()
    {
    int cou=Session.Keys.Count;
    for(int i=0;i<cou;i++)
    {
    TableRow tr=new TableRow();

    TableCell tck=new TableCell();
    TableCell tcv=new TableCell();
    TableCell tcb=new TableCell();

    Label lbkey=new Label();
    Label lbv=new Label();
    //Button bt=new Button(); lbkey.Text=Session.Keys[i].ToString();
    lbv.Text=Session[i].ToString();
    //bt.Text="修改"; tck.Controls.Add(lbkey);
    tcv.Controls.Add(lbv);
    //tcb.Controls.Add(bt); tr.Cells.Add(tck);
    tr.Cells.Add(tcv);
    tr.Cells.Add(tcb); this.Table1.Rows.Add(tr);
    }
    }