Hashtable.Remove Method removes the element with the specified key from the Hashtable.
using System;
using System.Collections;
public class SamplesHashtable {
public static void Main() {
Hashtable myHT = new Hashtable();
myHT.Add( "1a", "The" );
myHT.Add( "1b", "quick" );
myHT.Add( "1c", "brown" );
PrintKeysAndValues( myHT );
myHT.Remove( "1b" );
PrintKeysAndValues( myHT );
}
public static void PrintKeysAndValues( Hashtable myHT ) {
foreach ( DictionaryEntry de in myHT )
Console.WriteLine( " {0}: {1}", de.Key, de.Value );
Console.WriteLine();
}
}
Related examples in the same category