RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TStrings.CompareStrings Method

Compares two strings.

Pascal
function CompareStrings(const S1: string; const S2: string): Integer; virtual;
C++
virtual __fastcall int CompareStrings(const AnsiString S1, const AnsiString S2);

TStrings uses CompareStrings internally to compare the values of strings that appear in the list. For example, the IndexOf and IndexOfName methods use CompareStrings to compare a specified string with the strings in the list. 

S1 and S2 are the strings to compare. 

CompareStrings returns a value less than 0 if S1 < S2, 0 if S1 == S2, and a value greater than 0 if S1 > S2. 

As implemented in TStrings, CompareStrings uses the global AnsiCompareText function, which compares strings case insensitively. Some descendant classes override this method to change the way strings are compared (for example, to introduce case sensitivity). 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!