Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DateTime.CompareTo Method

 

Compares the value of this instance to a specified DateTime value and indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

NameDescription
System_CAPS_pubmethodCompareTo(DateTime)

Compares the value of this instance to a specified DateTime value and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

System_CAPS_pubmethodCompareTo(Object)

Compares the value of this instance to a specified object that contains a specified DateTime value, and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

The two overloads of the CompareTo method return a signed number that indicates the relative value of this instance and the value argument, as shown in the following table.

Value

Description

Less than zero

This instance is earlier than value.

Zero

This instance is the same as value.

Greater than zero

This instance is later than value.

Return to top
Show:
© 2017 Microsoft