Difference between revisions of "String.Compare"
From Xojo Documentation
(→Notes: Changed from constant to enum for CaseSensitive in description) |
|||
Line 30: | Line 30: | ||
By default comparisons are done in an invariant locale (i.e. not dependent on the user's preferences). The locale parameter can be used to specify an explicit locale to do comparisons in. | By default comparisons are done in an invariant locale (i.e. not dependent on the user's preferences). The locale parameter can be used to specify an explicit locale to do comparisons in. | ||
− | + | [[RuntimeException]] when the specified options are invalid. | |
− | |||
== Sample Code == | == Sample Code == |
Revision as of 23:18, 24 January 2022
Supported for all project types and targets.
Compares a String value with another string value. A non-empty String is always greater than an empty String. By default, a case-insensitive comparison is done. Returns a negative integer if the value is less than other, 0 if the two values are equal, and a positive integer if the value is greater than other.
Parameters
Parameter | Description |
---|---|
other | The String to compare with the original String. |
compare | (Optional) Use the ComparisonOptions enum. |
locale | (Optional) The locale to use for comparisons. By default an invariant locale (not dependent on the system settings) is used. |
Notes
By default this performs a case-insensitive comparison. To do a case-sensitive comparison, supply the ComparisonOptions.CaseSensitive enum value to the compare parameter.
By default comparisons are done in an invariant locale (i.e. not dependent on the user's preferences). The locale parameter can be used to specify an explicit locale to do comparisons in.
RuntimeException when the specified options are invalid.
Sample Code
Compare two String values: