System.Classes.TStringList.Add

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Add(const S: string): Integer; override;

C++

virtual int __fastcall Add(const System::UnicodeString S);

Properties

Type Visibility Source Unit Parent
function public
System.Classes.pas
System.Classes.hpp
System.Classes TStringList

Description

Adds a new string to the list.

Call Add to add the string S to the list. If the list is sorted, S is added to the appropriate position in the sort order. If the list is not sorted, S is added to the end of the list. Add returns the position of the item in the list, where the first item in the list has a value of 0.

Note: For sorted lists, Add will raise an EListError exception if the string S already appears in the list and Duplicates is set to dupError. If Duplicates is set to dupIgnore, trying to add a duplicate string causes Add to return the index of the existing entry.

See Also

Code Examples