C# 哈希表(Hashtable)

Hashtable类代表了一系列基于键的哈希代码组织起来的key/value对。他使用键来访问集合中的元素。

using System;using System.Collections;namespace CollectionsApplication{ class Program {static void Main(string[] args){Hashtable ht = new Hashtable();ht.Add("001", "Zara Ali");ht.Add("002", "Abida Rehman");ht.Add("003", "Joe Holzner");ht.Add("004", "Mausam Benazir Nur");ht.Add("005", "M. Amlan");ht.Add("006", "M. Arif");ht.Add("007", "Ritesh Saikia");if (ht.ContainsValue("Nuha Ali")){Console.WriteLine("This student name is already in the list");}else{ht.Add("008", "Nuha Ali");}// 获取键的集合ICollection key = ht.Keys;foreach (string k in key){Console.WriteLine(k + ": " + ht[k]);}Console.ReadKey();} }}

,获致幸福的不二法门是珍视你所拥有的、遗忘你所没有的

C# 哈希表(Hashtable)

相关文章:

你感兴趣的文章:

标签云: