Export (0) Print
Expand All

String.Compare Method

Updated: January 2011

Compares two specified String objects and returns an integer that indicates their relationship to one another in the sort order.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  NameDescription
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, String) Compares two specified String objects and returns an integer that indicates their relationship to one another in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, String, Boolean) Compares two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relationship to one another in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, String, StringComparison) Compares two specified String objects. A parameter specifies whether the comparison uses the current or invariant culture, honors or ignores case, and uses word or ordinal sort rules. The method returns an integer that indicates the relationship of the two String objects to one another in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, String, Boolean, CultureInfo) Compares two specified String objects, ignoring or honoring their case, and using culture-specific information to influence the comparison, and returns an integer that indicates their relationship to one another in the sort order.
Public method Static member Compare(String, String, CultureInfo, CompareOptions) Compares two specified String objects using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two strings to each other in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, Int32, String, Int32, Int32) Compares substrings of two specified String objects and returns an integer that indicates their relative position in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, Int32, String, Int32, Int32, Boolean) Compares substrings of two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relationship to one another in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, Int32, String, Int32, Int32, StringComparison) Compares substrings of two specified String objects and returns an integer that indicates their relationship to one another in the sort order.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Compare(String, Int32, String, Int32, Int32, Boolean, CultureInfo) Compares substrings of two specified String objects, ignoring or honoring their case and using culture-specific information to influence the comparison. The method returns an integer that indicates their relationship to one another in the sort order.
Public method Static member Compare(String, Int32, String, Int32, Int32, CultureInfo, CompareOptions) Compares substrings of two specified String objects using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two substrings to each other in the sort order.
Top

Caution noteCaution:

Whenever possible, you should call an overload of the Compare method that includes a StringComparison parameter.

Date

History

Reason

January 2011

Added the Remarks section.

Information enhancement.

Community Additions

ADD
Show:
© 2014 Microsoft