class Application8
{ static void Main(string[] args)
{
Hashtable str1 = new Hashtable();
Hashtable str2 = new Hashtable();
str1.Add("str1a", "str1aa");
str1.Add("str1b","str1bb");
str2.Add("str2a", "str2aa");
str2.Add("str2b", "str2bb");
str1.Add("str1->str2", str2);
foreach(DictionaryEntry de in str1)
{
if (de.Value is Hashtable)
{
Hashtable dd = (Hashtable)de.Value;
foreach (DictionaryEntry df in dd)
{
Console.WriteLine(df.Key + "---" + df.Value);
}
}
else
{
Console.WriteLine(de.Key + "---" + de.Value);
}
}
Console.Read();
}
}测试好的,只要把key和value换成数据库读的数据就可以了
{ static void Main(string[] args)
{
Hashtable str1 = new Hashtable();
Hashtable str2 = new Hashtable();
str1.Add("str1a", "str1aa");
str1.Add("str1b","str1bb");
str2.Add("str2a", "str2aa");
str2.Add("str2b", "str2bb");
str1.Add("str1->str2", str2);
foreach(DictionaryEntry de in str1)
{
if (de.Value is Hashtable)
{
Hashtable dd = (Hashtable)de.Value;
foreach (DictionaryEntry df in dd)
{
Console.WriteLine(df.Key + "---" + df.Value);
}
}
else
{
Console.WriteLine(de.Key + "---" + de.Value);
}
}
Console.Read();
}
}测试好的,只要把key和value换成数据库读的数据就可以了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货