XE2 Generics Exercise 1

Source: Internet
Author: User

To reference a cell System.Generics.Collections

Implementation

{$R *.DFM}
Var
I:integer;
str:string;

Procedure Tform1.btn2click (Sender:tobject);
Var
list:tlist<integer>;
Begin
List: = Tlist<integer>. Create ();
List.addrange ([11, 22, 33]);
str: = ';
For I in the List do
str: = str + INTTOSTR (i) + ";
ShowMessage (str); {11 22 33}
List.free;

End

Procedure Tform1.btn3click (Sender:tobject);
Var
list:tlist<string>;
item:string;
Begin
List: = Tlist<string>. Create ();
List.addrange ([' 123 ', ' 546 ', ' string ')];
str: = ';
For item in the List do
str: = str + item + ';
ShowMessage (str); {11 22 33}
List.free;

End

In case the blog park generic URL http://www.cnblogs.com/del/category/213198.html

//You can specify the sequencer at the same time as SetupprocedureTform1.button3click (sender:tobject);varlist:tlist<Integer>; Comparer:icomparer<Integer>;begin  {set up a sequencer}Comparer:= tcomparer<integer>. Construct (function(Constn1,n2:integer): IntegerbeginResult:= N2-N1; End  ); List:= Tlist<integer>.Create(comparer); List.addrange ([2,3,1]); List.sort; {is sorted based on the sequencer specified at the time of establishment}Str:="';  forIinchList Dostr: = str + INTTOSTR (i) +' '; ShowMessage (str); {3 2 1}List.free;End;

XE2 Generics Exercise 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.