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();
}
}
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();
}
}
改为
for(int i=0 ; i<result.Count;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();
}
}
{
IDictionaryEnumerator ie = (Hashtable)result[i].GetEnumerator();
while (ie.MoveNext())
{
tmpstr=tmpstr+";"+ie.Key.ToString()+","+ ie.Value.ToString();
}
}
很明显,i<=result.Count错了,一楼的已经说了。for(int i=0 ;i<=4;i++)的结果result.Count是5