Description |
Returns an IEnumerator object that allows the contents of the current HashTable to be read.
A call to MoveNext must be performed before a value can be read from the enumerator - the starting position is before the first element.
|
| References | IEnumerator
|
|
Microsoft MSDN Links |
System.Collections
System.Collections.HashTable
|
|
|
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['FirstName'] := 'Neil';
MyTable['LastName'] := 'Moffatt';
MyTable['Profession'] := 'Computer Programmer';
MyTable['Age'] := TObject(47);
MyTable['Birthday'] := DateTime.Create(1957, 2, 18);
// Get an enumerator for the HashTable
Enumerator := MyTable.GetEnumerator;
// Display the array contents using the enumerator
while Enumerator.MoveNext do
begin
DictEntry := DictionaryEntry(Enumerator.Current);
Console.WriteLine('{0} = {1}',
DictEntry.Key.ToString,
DictEntry.Value.ToString);
end;
Console.Readline;
end.
| Show full unit code | FirstName = Neil
Age = 47
Bithday = 18/02/1957 00:00:00
LastName = Moffatt
Profession = Computer Programmer
|
|
|
|