2中方法
Remove();
Clear();
static void Main(string[] args) { Hashtable ht = new Hashtable(); ht.Add(1,"张三"); ht.Add(true,"李四"); ht.Add(3,"王五"); foreach (DictionaryEntry item in ht) { Console.WriteLine("键{0},值{1}",item.Key,item.Value); } Console.WriteLine("-------------------------------------"); ht.Remove(1); //移除键为1的列 foreach (DictionaryEntry item in ht) { Console.WriteLine("键{0},值{1}", item.Key, item.Value); } Console.Read(); ht.Clear();//清空所有元素 }
原文:https://www.cnblogs.com/xiaowie/p/9125648.html