Last active
September 5, 2018 11:07
-
-
Save tkovs/909ae6f19bafc0d5052b0fa6c6f7461a to your computer and use it in GitHub Desktop.
TStringList como key->value de string e objeto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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