Description |
Returns an IDictionaryEnumerator object that allows the contents of the current SortedList 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 | IDictionaryEnumerator
|
|
Microsoft MSDN Links |
System.Collections
System.Collections.SortedList
|
|
|
Geting all elements from an SortedList |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Collections;
var
MyList : System.Collections.SortedList;
DictEntry : DictionaryEntry;
Enumerator : IEnumerator;
begin
// Create our sorted List
MyList := SortedList.Create;
// Add entries to it
MyList['FirstName'] := 'Neil';
MyList['LastName'] := 'Moffatt';
MyList['Profession'] := 'Computer Programmer';
MyList['Age'] := TObject(47);
MyList['Birthday'] := DateTime.Create(1957, 2, 18);
// Get an enumerator for the SortedList
Enumerator := MyList.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 | Age = 47
Birthday = 18/02/1957 00:00:00
FirstName = Neil
LastName = Moffatt
Profession = Computer Programmer
|
|
|
|