Date |
public int CompareTo( DateRange other )
Value | meaning |
---|---|
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 |
Zero | This instance is equal to or contained withinother |
Zero | This 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 |
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