|
|
A simple example |
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 the Source list
MyList['Name'] := 'Neil Moffatt';
MyList['Manager'] := 'Steven Hemingway';
MyList['Mentor'] := 'Danny Thorpe';
// Display the Sorted list
Enumerator := MyList.GetEnumerator;
while Enumerator.MoveNext do
begin
DictEntry := DictionaryEntry(Enumerator.Current);
Console.WriteLine('{0} = {1}',
DictEntry.Key.ToString,
DictEntry.Value.ToString);
end;
Console.WriteLine;
if MyList.ContainsValue('Steven Hemingway')
then Console.WriteLine('''Steven Hemingway'' value found')
else Console.WriteLine('''Steven Hemingway'' value not found');
if MyList.ContainsValue('Born Borg')
then Console.WriteLine('''Born Borg'' value found')
else Console.WriteLine('''Born Borg'' value not found');
Console.Readline;
end.
| Show full unit code | Manager = Steven Hemingway
Mentor = Danny Thorpe
Name = Neil Moffatt
'Steven Hemingway' value found
'Born Borg' value not found
|
|
|
|