Share via


String.Compare Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Include Protected Members
Include Inherited Members

Include Silverlight Members
Include Silverlight for Windows Phone Members
Include XNA Framework Members

Compares two specified String objects and returns an integer that indicates their relative position 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.

Overload List

  Name Description
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Compare(String, String) Performs a culture-sensitive comparison of two specified String objects and returns an integer that indicates their relationship to one another in the sort order.
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Compare(String, String, StringComparison) Compares two specified String objects using the specified string comparison options and returns an integer that indicates their relationship to one another in the sort order.
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 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 one another in the sort order.
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Compare(String, Int32, String, Int32, Int32) Performs a culture-sensitive comparison of substrings that are extracted from two specified String objects and returns an integer that indicates their relationship to one another in the sort order.
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Compare(String, Int32, String, Int32, Int32, StringComparison) Compares substrings of two specified String objects using the specified string comparison options and returns an integer that indicates their relationship to one another in the sort order.
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 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 one another in the sort order.

Top

Remarks

Caution noteCaution:

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

See Also

Reference

Change History

Date

History

Reason

Added the Remarks section.

Information enhancement.