DateRangeCompareTo(DateTimeOffset) Method

Compares this instance to a specified DateTimeOffset structure and returns an indication of their relative values.

Definition

Namespace: InnerDrive.Core
Assembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.2.9017.0
C#
public int CompareTo(
	DateTimeOffset other
)

Parameters

other  DateTimeOffset
A DateTimeOffset structure to compare, or a null reference.

Return Value

Int32
A signed number indicating the relative values of this instance and other. The return value has these meanings:
Valuemeaning
Less than zero Both the Lower and Upper members of this DateRange are less than other
- or -
Both the Lower and Upper members of this DateRange are less than or equal to other and IsUpperInclusive is false
ZeroThis instance is equal to or contains other
Greater than zero Both the Lower and Upper members of this DateRange are greater than other
- or -
Both the Lower and Upper members of this DateRange are greater than or equal to other and IsLowerInclusive is false

Example

The following illustrates how a DateRange compares to various DateTimeOffset objects:
C#
DateTimeOffset early = DateTimeOffset.Now.AddHours(-1);
DateTimeOffset late = DateTimeOffset.Now.AddHours(1);
DateRange earlyToLate = new DateRange(early, late);

earlyToLate.CompareTo(DateTimeOffset.Now);
--> 0

earlyToLate.CompareTo(early);
--> 0

earlyToLate.CompareTo(early.AddHours(-1));
--> -1

earlyToLate.CompareTo(late);
--> 0

earlyToLate.CompareTo(late.AddHours(1));
--> 1

See Also