给动态数组一次性赋值

delphi中动态数组通过const的方式来赋值方法,网上已经很多,我要介绍的是局部动态数组变量的一次性赋值,以下为代码

procedure TFrm_Main.CreateTalent; var InfoList:TStrings; str,InfoBlock,InfoCaption:string; i:integer; PersonInfo:array of string; begin //下面这行是关键 PersonInfo:=VarArrayOf(['姓名','工作年限','手机','居住地', '电子邮件','学历','户口','出生日期','专业','性别','地址']); InfoList:=TStringList.Create; try InfoBlock:='个人信息'; if GetInfoBlock(InfoList,InfoBlock) then begin for i:=Low(PersonInfo) to High(PersonInfo) do begin if PersonInfo[i]='姓名' then Memo2.Lines.Add(PersonInfo[i]+':'+GetCaption(InfoList,InfoBlock,PersonInfo[i],'')) else Memo2.Lines.Add(PersonInfo[i]+':'+GetCaption(InfoList,InfoBlock,PersonInfo[i])); end; end; finally FreeAndNil(InfoList); end; end;

你可能感兴趣的:(软件开发)