IList result = new ArrayList();
try
{
for(int i=0 ;i<=4;i++)
{
System.Collections.Hashtable htTmp = new Hashtable();
htTmp.Add("tableWidth","8%");
htTmp.Add("showFieldName","客户id"+i.ToString());
htTmp.Add("showFieldValue","customerid");
htTmp.Add("order",i.ToString());//表示是否排序  
result.Add(htTmp);

}
}catch()
{}怎样把result的数据读出来。我下面的代码有问题,帮我看看
string tmpstr="';
for(int i=0 ; i<=result.Count;i++)
{
Hashtable hs =result[i] as Hashtable;
foreach (DictionaryEntry myDE in hs)
{
tmpstr=tmpstr+";"+myDE.Key.ToString()+","+myDE.Value.ToString();
}
}

解决方案 »

  1.   

    什么问题,是“超出索引”吗?for(int i=0 ; i<=result.Count;i++)
    改为
    for(int i=0 ; i<result.Count;i++)
      

  2.   

    IList result = new ArrayList(); for(int i=0 ;i<=4;i++)
    {
    System.Collections.Hashtable htTmp = new Hashtable();
    htTmp.Add("tableWidth","8%");
    htTmp.Add("showFieldName","客户id"+i.ToString());
    htTmp.Add("showFieldValue","customerid");
    htTmp.Add("order",i.ToString());//表示是否排序  
    result.Add(htTmp);
    }
    //怎样把result的数据读出来。我下面的代码有问题,帮我看看
    string tmpstr="";
    for(int i=0 ; i<result.Count;i++)
    {
    Hashtable hs =(Hashtable)result[i];
    foreach (DictionaryEntry myDE in hs)
    {
    tmpstr=tmpstr+";"+myDE.Key.ToString()+","+myDE.Value.ToString();
    }
    }
      

  3.   

    Hashtable hs =(Hashtable)result[i] ;
      

  4.   

    string tmpstr="";for(int i=0; i<result.Count;i++)

      IDictionaryEnumerator ie = (Hashtable)result[i].GetEnumerator();
      while (ie.MoveNext())
      {
        tmpstr=tmpstr+";"+ie.Key.ToString()+","+ ie.Value.ToString();
      }
    }
      

  5.   

    都是引用类型,不是装箱拆箱的问题。
    很明显,i<=result.Count错了,一楼的已经说了。for(int i=0 ;i<=4;i++)的结果result.Count是5