DateTime.CompareTo Method (DateTime)
Assembly: mscorlib (in mscorlib.dll)
public final int CompareTo ( DateTime value )
public final function CompareTo ( value : DateTime ) : int
Not applicable.
Parameters
- value
A DateTime object to compare.
Return Value
A signed number indicating the relative values of this instance and the value parameter.| 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. |
This method implements the System.IComparable interface and performs slightly better than the DateTime.CompareTo(Object) method overload because it does not have to convert the value parameter to an object.
Before comparing DateTime objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their Kind properties.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.