Skip to main content
.NET Framework Class Library
StringIComparableCompareTo Method

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)
Syntax
Private Function CompareTo ( _
	value As [%$TOPIC/hh924458_en-us_VS_110_1_0_0_0_0%] _
) As [%$TOPIC/hh924458_en-us_VS_110_1_0_0_0_1%] Implements [%$TOPIC/hh924458_en-us_VS_110_1_0_0_0_2%].[%$TOPIC/hh924458_en-us_VS_110_1_0_0_0_3%]
[%$TOPIC/hh924458_en-us_VS_110_1_0_1_0_0%] [%$TOPIC/hh924458_en-us_VS_110_1_0_1_0_1%].[%$TOPIC/hh924458_en-us_VS_110_1_0_1_0_2%](
	[%$TOPIC/hh924458_en-us_VS_110_1_0_1_0_3%] value
)
private:
virtual [%$TOPIC/hh924458_en-us_VS_110_1_0_2_0_0%] CompareTo(
	[%$TOPIC/hh924458_en-us_VS_110_1_0_2_0_1%]^ value
) sealed = [%$TOPIC/hh924458_en-us_VS_110_1_0_2_0_2%]::[%$TOPIC/hh924458_en-us_VS_110_1_0_2_0_3%]
private abstract CompareTo : 
        value:[%$TOPIC/hh924458_en-us_VS_110_1_0_3_0_0%] -> [%$TOPIC/hh924458_en-us_VS_110_1_0_3_0_1%]  
private override CompareTo : 
        value:[%$TOPIC/hh924458_en-us_VS_110_1_0_3_0_2%] -> [%$TOPIC/hh924458_en-us_VS_110_1_0_3_0_3%]

Parameters

value
Type: SystemObject

An object to compare with this instance, or .

Return Value

Type: SystemInt32
A signed integer that indicates the relative order of this instance and value.

Return value

Meaning

Less than zero

This instance precedes value in the sort order.

Zero

This instance occurs in the same position as value in the sort order.

Greater than zero

This instance follows value in the sort order.

-or-

value is .

Implements

IComparableCompareTo(Object)
Exceptions
ExceptionCondition
ArgumentException

value is not a String.

Remarks

This member is an explicit interface implementation. It can be used only when the String instance is cast to an IComparable interface.

Version Information

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8