System.TObject.DisposeOf

提供: RAD Studio API Documentation
移動先: 案内検索

Delphi

procedure DisposeOf; {$IFNDEF AUTOREFCOUNT} inline; deprecated 'Use Free instead'; {$ENDIF}

C++

void __fastcall DisposeOf();

プロパティ

種類 可視性 ソース ユニット
procedure
function
public
System.pas
systobj.h
System TObject


説明

DisposeOf は、オブジェクトでのデストラクタ コードの実行を強制します。

これは、Delphi モバイル コンパイラが自動参照カウントをサポートしていた以前のバージョンからの機能です。現行バージョンの Delphi では、DisposeOf は、TObject.Free を起動するラッパーとして使用されます。

type
  TMySimpleClass = class
  private
    stringMember: String;
    constructor Create(const Text: String);
    destructor Destroy;
  end;

constructor TMySimpleClass.Create(const Text: String);
begin
  stringMember := Text;
end;

destructor TMySimpleClass.Destroy;
begin
  // this will be executed on calling the DisposeOf method.
end;

var
  myObject: TMySimpleClass;
begin
  myObject := TMySimpleClass.Create('This is a code snippet indicating the usage of the DisposeOf method');
  try
    // Use 'myObject' here
  finally
    myObject.DisposeOf;
  end;
end.

関連項目