CSharp examples for Collection:Hashtable
Check value existance in Hashtable
using System;//from w w w . ja va2s.c o m using System.Collections; class Program { static void Main(string[] args) { Hashtable ht = new Hashtable(); ht.Add("001", "Z"); ht.Add("002", "A"); ht.Add("003", "J"); ht.Add("004", "M"); if (ht.ContainsValue("N")) { Console.WriteLine("This student name is already in the list"); } else { ht.Add("008", "N"); } // Get a collection of the keys. ICollection key = ht.Keys; foreach (string k in key) { Console.WriteLine(k + ": " + ht[k]); } } }