[英]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)) 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?他们是否在减去时间并基本上试图查看它们是否相隔不到 1 秒?
Subtracting one DateTime variable from another one will return you a TimeSpan typed result.从另一个变量中减去一个 DateTime 变量将返回一个 TimeSpan 类型的结果。 The code compares the result to decide if the difference is more than a second.代码比较结果以确定差异是否超过一秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.