详测 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.
相关文章推荐
- 十六、详测 Generics Collections TList (7): Items、Contains
- 详测 Generics Collections TList (4): AddRange、InsertRange、DeleteRange
- 十、详测 Generics Collections TList (1): Add、Clear、Count、Capacity
- 十八、详测 Generics Collections TList (9): BinarySearch
- 二十五、详测 Generics Collections TDictionary(1): Add、Items、Keys、Values、Remove
- 详测 Generics Collections TList (9): BinarySearch
- Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
- 十一、详测 Generics Collections TList (2): First、Last、IndexOf、LastIndexOf
- 十九、详测 Generics Collections TList (10): OnNotify 事件
- 二十六、详测 Generics Collections TDictionary(2): ContainsKey、ContainsValue、AddOrSetValue、TryGetValue
- 详测 Generics Collections TList (6): Reverse、TrimExcess
- 十二、详测 Generics Collections TList (3): Insert、Delete、Remove、Extract
- 二十、详测 Generics Collections TList (11): Create
- 详测 Generics Collections TList (8): Sort
- 详测 Generics Collections TDictionary(1): Add、Items、Keys、Values、Remove
- 二、Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
- 十三、详测 Generics Collections TList (4): AddRange、InsertRange、DeleteRange
- [导入]Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList
- 详测 Generics Collections TList (9): BinarySearch