您的位置:首页 > 大数据 > 人工智能

详测 Generics Collections TList (7): Items、Contains

2009-10-11 01:19 585 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: