您的位置:首页 > 其它

给动态数组一次性赋值

2010-06-06 20:45 183 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: