-3

The title says it all. I'm subtracting two DateTimes and I want to see if the returned Timespan is negative. How do I do this?

// dt1 and dt2 are DateTimes.
TimeSpan ts = dt1.Subtract(dt2);
ts.isNegative() // or something like that

1 Answers1

6

TimeSpan has a Compare method on it, or you can do < TimeSpan.Zero or you could have just compared the two DateTimes in the first place and skipped creating the TimeSpan entirely.

Ian Mercer
  • 38,490
  • 8
  • 97
  • 133