Last Property Example

The following program code displays the subscript and value of the last item in a Mult variable in the caption of a label when the user clicks the GetLast button:

procedure TForm1.GetLastClick(Sender: TObject);
var
  Mult: TMult;
  Subscript: string;
begin
  Mult := TMult.Create(Form1);      {Create Mult. Make Form1 its owner}
  Mult['Fruit'] := 'Apple';
  Mult['Vegetable'] := 'Potato';    {Store element pairs one by one}
  Label1.Caption := 'The subscript of the last element: ' + Mult.Last +
    ', and its value: ' + Mult[Mult.Last];
end;