Adding a String to a List

From RAD Studio
Jump to: navigation, search

Go Up to Manipulating Strings in a List


To add a string to the end of a string list, call the Add method, passing the new string as the parameter. To insert a string into the list, call the Insert method, passing two parameters: the string and the index of the position where you want it to be placed. For example, to make the string "Three" the third string in a list, you would use:

Delphi:

Insert(2, 'Three');

C++:

StringList1->Insert(2, "Three");

To append the strings from one list onto another, call AddStrings:

Delphi:

StringList1.AddStrings(StringList2);  { append the strings from StringList2 to StringList1 }

C++:

StringList1->AddStrings(StringList2); // append the strings from StringList2 to StringList1

See Also