Home  |  Delphi .net Home  |  System.Collections.HashTable  |  Remove Method
  
Remove  
Method  
Remove a key-value entry from the current HashTable
HashTable Class
System.Collections NameSpace
CF1.  Procedure Remove ( Key : Object ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
If the specified Key is found in the current HashTable, it is removed, and Count for the HashTable is decremented.
Microsoft MSDN Links
System.Collections
System.Collections.HashTable
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  MyTable    : System.Collections.HashTable;
  DictEntry  : DictionaryEntry;
  Enumerator : IEnumerator;

begin
  // Create our hash table
  MyTable := HashTable.Create;

  // Add entries to it
  MyTable['Name']     := 'Neil Moffatt';
  MyTable['Birthday'] := DateTime.Create(1957, 2, 18);
  MyTable['Age']      := TObject(47);

  // Display the table contents
  Console.WriteLine('MyTable at the start :');
  Console.WriteLine;
  Enumerator := MyTable.GetEnumerator;
  while Enumerator.MoveNext do
  begin
    DictEntry := DictionaryEntry(Enumerator.Current);
    Console.WriteLine('{0} = {1}',
                      DictEntry.Key.ToString,
                      DictEntry.Value.ToString);
  end;

  // Now remove the Age entry
  MyTable.Remove('Age');

  // Display the table contents
  Console.WriteLine;
  Console.WriteLine('MyTable after removing ''Age'' :');
  Console.WriteLine;
  Enumerator := MyTable.GetEnumerator;
  while Enumerator.MoveNext do
  begin
    DictEntry := DictionaryEntry(Enumerator.Current);
    Console.WriteLine('{0} = {1}',
                      DictEntry.Key.ToString,
                      DictEntry.Value.ToString);
  end;

  Console.Readline;
end.
   MyTable at the start :
  
   Birthday = 18/02/1957 00:00:00
   Age = 47
   Name = Neil Moffatt
  
   MyTable after removing 'Age' :
  
   Birthday = 18/02/1957 00:00:00
   Name = Neil Moffatt
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author