HashTable ht = new HashTable();

foreach(DictionaryEntry xx in ht)

{

     Response.Write(xx.Key);  

     Response.Write(xx.Value);

}

 

有了泛型字典我们就可以这样用

 

Dictionary<string,string> dt = new Dictionary<string,string>();

foreach(KeyValuePair<string,string> xx in dt)

{

     Response.Write(xx.Key);  

     Response.Write(xx.Value);

}

 

虽然功能差不多,但Dictionary 继承了IEnumerator接口,提供了更多泛型特有的方法给我们用,具体的大家用Reflector反编译一下看下源代码了

相关文章:

  • 2021-09-25
  • 2021-12-30
  • 2021-05-11
  • 2021-09-30
  • 2022-12-23
  • 2021-05-28
  • 2021-07-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2022-01-28
  • 2022-01-19
  • 2021-07-05
相关资源
相似解决方案