简体   繁体   中英

In C#, what would a Timespan.FromSeconds(-1) mean when used in a comparison?

Some code I was reading recently did a time calculation something like:

if (TimeWhenResponseArrived - TimeWhenRequested > Timespan.FromSeconds(-1))

I am having a hard time understanding what is trying to be done here. Are they subtracting the times and basically trying to see if they are less than 1 second apart?

Subtracting one DateTime variable from another one will return you a TimeSpan typed result. The code compares the result to decide if the difference is more than a second.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM