Show: Object Pascal C++
Display Preferences

Adding a String to a List

From Appmethod Topics
Jump to: navigation, search

Go Up to Working with String Lists

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 placed. For example, to make the string "Three" the third string in a list, you would use:

Object Pascal:

Insert(2, 'Three');

C++:

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

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

Object Pascal:

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

C++:

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

See Also

Personal tools
In other languages