Entweder man studiert den Sourcecode von
TObjectList.Delete
und
TObjectList.Remove
oder man schreibt ein kleines
Testprogramm:
Delphi-Quellcode:
type
TTestObj = class(TObject)
private
FInfo : string;
public
constructor Create(const Info:string);
destructor Destroy;override;
end;
constructor TTestObj.Create(const Info:string);
begin
inherited Create;
FInfo := Info;
ShowMessageFmt('%s erzeugt', [Info]);
end;
destructor TTestObj.Destroy;override;
begin
ShowMessageFmt('%s destroyed', [FInfo]);
inherited;
end;
var
olist : TObjectList;
begin
olist := TObjectList.create({OwnsObjects=}True);
olist.Add(TTestObj.Create('Object A');
olist.Delete(0);
olist.Add(TTestObj.Create('Object B');
olist.Remove(0);
ShowMessage('vor [TObjectList].Free...');
olist.Free;