# Guid.IComparable.CompareTo(Object) Method

## Definition

`` virtual int System.IComparable.CompareTo(System::Object ^ value) = IComparable::CompareTo;``
``int IComparable.CompareTo (object value);``
``````abstract member System.IComparable.CompareTo : obj -> int
override this.System.IComparable.CompareTo : obj -> int``````
``Function CompareTo (value As Object) As Integer Implements IComparable.CompareTo``

value
Object

#### Returns

Int32

Zero此实例等于 `value`This instance is equal to `value`.

## Remarks

`CompareTo` 方法将 Guid 视为向 Guid(Int32, Int16, Int16, Byte[]) 构造函数提供的值进行比较，如下所示：The `CompareTo` method compares the GUIDs as if they were values provided to the Guid(Int32, Int16, Int16, Byte[]) constructor, as follows:

• 它比较 UInt32 值，如果结果不相等，则返回结果。It compares the UInt32 values, and returns a result if they are unequal. 如果它们相等，则执行下一次比较。If they are equal, it performs the next comparison.
• 它比较第一个 UInt16 值，如果结果不相等，则返回结果。It compares the first UInt16 values, and returns a result if they are unequal. 如果它们相等，则执行下一次比较。If they are equal, it performs the next comparison.
• 它比较第二个 UInt16 值，如果结果不相等，则返回结果。It compares the second UInt16 values, and returns a result if they are unequal. 如果它们相等，则执行下一次比较。If they are equal, it performs the next comparison.
• 如果对接下来的八个 Byte 值执行逐字节的比较。If performs a byte-by-byte comparison of the next eight Byte values. 如果遇到第一个不相等对，则返回结果。When it encounters the first unequal pair, it returns the result. 否则，它将返回0，表示两个 Guid 值相等。Otherwise, it returns 0 to indicate that the two Guid values are equal.