測試代碼:
unitUnit1;
interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,
Dialogs,StdCtrls;
type
TForm1=class(TForm)
Edit1:TEdit;
procedureFormCreate(Sender:TObject);
private
{Privatedeclarations}
type
TMyRec=record
Id:Integer;
Name:String;
Age:Integer;
end;
PTMyRec=^TMyRec;
public
{Publicdeclarations}
end;
var
Form1:TForm1;
implementation
{$R*.dfm}
procedureTForm1.FormCreate(Sender:TObject);
var
PsnInfo:PTMyRec;
PsnList:TList;
begin
PsnList:=TList.Create;
new(PsnInfo);
PsnInfo^.Id :=1;
PsnInfo^.Name:='ShenBin';
PsnInfo^.Age :=28;
PsnList.Add(PsnInfo);
PsnList.Add(PsnInfo);
ShowMessage(IntToStr(PsnList.Count));
end;
end.
更多測試代碼可參閱:http://www.cnblogs.com/del/archive/2007/12/29/1019566.Html