获取所有Hashtable 键值只需用到GetEnumerator()方法。
如下:
Hashtable a = new Hashtable();
a["a"] = "fda";
a["a1"] = "fda";
a["a2"] = "fda";
IDictionaryEnumerator CacheEnum1 = a.GetEnumerator();
string str= string.Empty;
while (CacheEnum1.MoveNext())
{
str+= "," + CacheEnum1.Entry.Key.ToString();
}
即str=,a2,a1,a
清除所有缓存
IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Entry.Key.ToString());
}
GetEnumerator方法应用---获取Hashtable所有键值及清除所有缓存
浙公网安备 33010602011771号