DateRangeCompareTo(DateRange) Method

Compares the current instance with another DateRange.

Definition

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

Parameters

other  DateRange
A DateRange to compare with this instance.

Return Value

Int32
A 32-bit signed integer that indicates the relative order of the comparands. The return value has these meanings:
Valuemeaning
Less than zero The Upper and Lower members of this instance are less than those members of other
- or -
The Upper member of this instance is equal to the Lower member of other but the Lower member of this instance is less than both
ZeroThis instance is equal to or contained withinother
ZeroThis instance is equal to or contained withinother
Greater than zero The Upper and Lower members of this instance are greater than those members of other
- or -
The Lower member of this instance is equal to the Upper member of other but the Upper member of this instance is greater than both

Implements

IComparableTCompareTo(T)

Example

The following illustrates how a DateRange compares to various other DateRange objects:
C#
DateTimeOffset early = DateTimeOffset.Now.AddHours(-1);
DateTimeOffset late = DateTimeOffset.Now.AddHours(1);
DateRange earlyToLate = new DateRange(early, late);
DateRange earlyToEarly = new DateRange(early.AddHours(-1), early.AddMinutes(-1));
DateRange lateToLate = new DateRange(late.AddMinutes(1), late.AddHours(1));
DateRange overlapping = new DateRange(early.AddHours(-1), late.AddHours(1));
earlyToLate.CompareTo(earlyToLate);
--> 0
earlyToLate.CompareTo(earlyToEarly);
--> 1
earlyToLate.CompareTo(lateToLate);
--> -1
earlyToLate.CompareTo(overlapping);
--> 0

See Also