用 TStringList 模拟 "将字符串转换为变量的功能" - 回复 "flq_00000" 和 "外来天客" 的问题

问题来源: http://www.cnblogs.com/del/archive/2008/09/03/989467.html#1306651


unit Unit1;



interface



uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs;



type

  TForm1 = class(TForm)

    procedure FormCreate(Sender: TObject);

  end;



var

  Form1: TForm1;



implementation



{$R *.dfm}



procedure TForm1.FormCreate(Sender: TObject);

const

  str1 = 'aaa';

  str2 = 'bbb';

var

  List: TStrings;

begin

  List := TStringList.Create;

  List.Add(str1 + '=123');

  List.Add(str2 + '=456');



  ShowMessage(List.Values['aaa']); {123}

  ShowMessage(List.Values['bbb']); {456}



  List.Free;

end;



end.


 
   

你可能感兴趣的:(String)