zoukankan      html  css  js  c++  java
  • 详测 Generics Collections TList (7): Items、Contains

    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.
    
  • 相关阅读:
    Catalan数
    C# & LINQ 对象克隆
    Rotate Image
    反转链表
    QtCreator调试程序时GDB崩溃
    Regular Expression Matching
    Wildcard Matching
    DFA与NFA
    Set Matrix Zeroes
    PCA原理
  • 原文地址:https://www.cnblogs.com/del/p/1580717.html
Copyright © 2011-2022 走看看