unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Generics.Collections;

procedure TForm1.Button1Click(Sender: TObject);
var
  List: TList<Byte>;
  b: Byte;
  str: string;
begin
  List := TList<Byte>.Create();
  List.AddRange([11,22,33,44]);

  List.Move(1, 2);
  str := '';
  for b in List do str := str + IntToStr(b) + ' '; {11 33 22 44 }
  ShowMessage(str);

  List.Exchange(0, 3);
  str := '';
  for b in List do str := str + IntToStr(b) + ' '; {44 33 22 11 }
  ShowMessage(str);

  List.Free;
end;

end.

posted on 2009-10-11 01:02  万一  阅读(1652)  评论(0编辑  收藏  举报