Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses generics. collections; Procedure tform1.button1click (Sender: tobject); var dictionary: tdictionary <string, integer>; K: string; V: integer; STR: strin G; begin dictionary: = tdictionary <string, integer>. create (); {Add} dictionary. add ('n1 ', 111); dictionary. add ('n2 ', 222); dictionary. add ('n3 ', 333); {access} showmessage (inttostr (Dictionary ['n2']); {222} showmessage (inttostr (dictionary. items ['n2 ']); {222} {traverse keys} STR: = ''; for K in dictionary. keys do STR: = STR + K + ''; showmessage (STR); {N2 N3 N1} // is the order disordered? {Traverse values} STR: = ''; for V in dictionary. values do STR: = STR + inttostr (v) + ''; showmessage (STR); {222 333 111} {traverse values through keys} STR: = ''; for k in dictionary. keys do STR: = STR + inttostr (Dictionary [k]) + ''; showmessage (STR); {222 333 111 }{ Delete} dictionary. remove ('n1 '); STR: = ''; for K in dictionary. keys do STR: = STR + inttostr (Dictionary [k]) + ''; showmessage (STR); {222 333} {count, clear} showmessage (inttostr (dictionary. count); {2} dictionary. clear; showmessage (inttostr (dictionary. count); {0} dictionary. free; end.