Skip to content

Instantly share code, notes, and snippets.

@tkovs
Last active September 5, 2018 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkovs/909ae6f19bafc0d5052b0fa6c6f7461a to your computer and use it in GitHub Desktop.
Save tkovs/909ae6f19bafc0d5052b0fa6c6f7461a to your computer and use it in GitHub Desktop.
TStringList como key->value de string e objeto
procedure Exemplo();
var
Nomes, NomesTemp: TStringList;
Nome, Temp: String;
Idade: Integer;
Objeto: TObject;
begin
Nomes := TStringList.Create();
Nomes.AddObject('João', TObject(21));
Nomes.AddObject('Luiz', TObject(13));
Nomes.AddObject('Otávio', TObject(27));
Nomes.AddObject('Josué', TObject(53));
Nomes.AddObject('Frederico', TObject(3));
for Nome in Nomes do
begin
Temp := Nome
end;
Objeto := TObject(Nomes);
NomesTemp := TStringList(Objeto);
for Nome in NomesTemp do
begin
Temp := Nome;
Idade := Integer(NomesTemp.Objects[NomesTemp.IndexOf(Nome)]);
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment