System.DateTimeOffset.Compare Method

Compares two DateTimeOffset objects and indicates whether the first is earlier than the second, equal to the second, or later than the second.

Syntax

public static int Compare (DateTimeOffset first, DateTimeOffset second)

Parameters

first
The first object to compare.
second
The second object to compare.

Returns

A signed integer that indicates whether the value of the first parameter is earlier than, later than, or the same time as the value of the second parameter, as the following table shows.

Less than zero

first is earlier than second.

Zero

first is equal to second.

Greater than zero

first is later than second.

Remarks

In performing the comparison, the method converts both the first and the second parameters to Coordinated Universal Time (UTC) before it performs the comparison. The method is equivalent to the following:

code reference: System.DateTimeOffset.Syntax#1

In other words, the DateTimeOffset.Compare(DateTimeOffset, DateTimeOffset) method determines whether two DateTimeOffset objects represent a single point in time. It directly compares neither dates and times nor offsets.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0