Hashtable.Contains Method determines whether the Hashtable contains a specific key.
using System; using System.Collections; public class SamplesHashtable { public static void Main() { Hashtable myHT = new Hashtable(); myHT.Add( 0, "zero" ); myHT.Add( 1, "one" ); myHT.Add( 2, "two" ); myHT.Add( 3, "three" ); myHT.Add( 4, "four" ); int myKey = 2; Console.WriteLine( myHT.ContainsKey( myKey ) ); myKey = 6; Console.WriteLine( myHT.ContainsKey( myKey ) ); String myValue = "three"; Console.WriteLine( myHT.ContainsValue( myValue ) ); myValue = "nine"; Console.WriteLine( myHT.ContainsValue( myValue ) ); } }