Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Add stringlists together containing objects

Title should say it all, but what is the best way to merge 2 stringlists,

1) 1 empty and one not empty containing objects
2) 2 both containing objects.
0
mikelittlewood
Asked:
mikelittlewood
  • 2
1 Solution
 
atul_parmarCommented:
var
  s1, s2 : TStringList;
  i : integer;
begin
  s1 := TStringList.Create;
  s2 := TStringList.Create;
  // fill your stringlist as you wish
  if (s1.Count = 0) then
    s1.Assign(s2)
  else
  begin
    for i := 0 to s2.Count - 1 do
      s2.AddObject(s2.Strings[i], s2.Objects[i]);
  end;
  s1.Free;
  s2.free;
end;
0
 
2266180Commented:
how about s1.addstrings(s2); ?
0
 
mikelittlewoodAuthor Commented:
I thought of that way too atul parmar, but was hoping there was a function to sue to do the job for me.

Thats what I was looking for thanks ciuly.
0
 
2266180Commented:
np :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now