[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'sysutils' (#rtl)

# TStringHelper.Compare

Compare 2 strings

## Declaration

Source position: syshelph.inc line 67

`public class function TStringHelper.Compare(`
`const A: string;`
`const B: string`
`):Integer; overload; class function TStringHelper.Compare(`
`const A: string;`
`const B: string;`
`IgnoreCase: Boolean`
`):Integer; overload; class function TStringHelper.Compare(`
`const A: string;`
`const B: string;`
`Options: TCompareOptions`
`):Integer; overload; class function TStringHelper.Compare(`
`const A: string;`
`IndexA: SizeInt;`
`const B: string;`
`IndexB: SizeInt;`
`ALen: SizeInt`
`):Integer; overload; class function TStringHelper.Compare(`
`const A: string;`
`IndexA: SizeInt;`
`const B: string;`
`IndexB: SizeInt;`
`ALen: SizeInt;`
`IgnoreCase: Boolean`
`):Integer; overload; class function TStringHelper.Compare(`
`const A: string;`
`IndexA: SizeInt;`
`const B: string;`
`IndexB: SizeInt;`
`ALen: SizeInt;`
`Options: TCompareOptions`
`):Integer; overload;`

## Description

Compare compares strings A and B. It returns the following result:

- 0 if the strings are equal
- a negative number if A < B
- a positive number if A > B

The comparison can be influenced by using the appropriate overloaded version of the function.

- If the IndexA and IndexB parameters are present, the comparison starts at character index IndexA and IndexB. The indexes are zero-based.
- If the ALen parameters is present, then only the first ALen characters are compared. If not enough characters are present in either A or B, the comparison will include only as much characters as are present.
- If IgnoreCase is present and used, it determines whether the comparison is done case-sensitively. This form is deprecated, it is recommended to use the AOptions parameter and to include coIgnoreCase.
- The AOptions argument can be used to specify additional options. See TCompareOption for a list of possible values in this set.

## Errors

None.

## See also

TStringHelper.CompareOrdinal |  | Compare 2 strings byte for byte
TCompareOption |  | How to compare strings
TStringHelper.CompareTo |  | Compare string to another

Documentation generated on: May 14 2021