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<string>;
  b: Boolean;
begin
  List := TList<string>.Create();
  List.AddRange(['AA', 'BB', 'CC']);

  ShowMessageFmt('%s : %s', [List[1], List.Items[1]]); {BB : BB}

  b := List.Contains('BB');
  ShowMessage(BoolToStr(b, True)); {True}

  b := List.Contains('DD');
  ShowMessage(BoolToStr(b, True)); {False}

  List.Free;
end;

end.

posted on 2009-10-11 01:19  万一  阅读(1934)  评论(2编辑  收藏  举报