首页 > 其他 > 详细

delphi下TList的用法

时间:2014-01-24 10:57:42      阅读:392      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type
  TMyRec = record
  Id: Integer;
  Name : String;
  Age : Integer;
  end;
 PTMyRec = ^TMyRec;
var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(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));
  PsnInfo:=PsnList.Items[1];
  ShowMessage(PsnInfo^.Name);
  Dispose(PsnInfo);
end;

end.
bubuko.com,布布扣

delphi下TList的用法

原文:http://www.cnblogs.com/China3S/p/3531858.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!