for in 循环

2018-11-25  本文已影响0人  netppp

https://www.cnblogs.com/xsiedu/articles/1741572.html

Java和C#里面的For In用起来真爽,我们Delphin也不用眼红了,从D2005起,Delphi里面也有这个功能了.

首先我们要知道哪些类型可以用For In吧,下面就是:

for Element in ArrayExpr do Stmt;      数组

for Element in StringExpr do Stmt;    字符串

for Element in SetExpr do Stmt;         集合

for Element in CollectionExpr do Stmt;   集合

for Element in Record do Stmt;         结构体

---------------------------------------------------------

procedure TForm3.Button1Click(Sender: TObject);  //遍历字符串

  var        a,b:string;

begin

    b:='abcdefg123';

    for  a in b  do

    Memo1.Lines.Add(a);

end;

上一篇 下一篇

猜你喜欢

热点阅读