gfrv 发表于 2015-9-11 08:48:50

详测 Generics Collections TList (5): Move、Exchange

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();
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.
页: [1]
查看完整版本: 详测 Generics Collections TList (5): Move、Exchange