简体   繁体   English

在 C# 中,Timespan.FromSeconds(-1) 用于比较时意味着什么?

[英]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.

相关问题 Timespan(0,0,secs)或Timespan.FromSeconds(secs) - Timespan(0,0,secs) or Timespan.FromSeconds(secs) 如何通过ConverterParameter将TimeSpan.FromSeconds传递给转换器? - How can I pass TimeSpan.FromSeconds to a converter via the ConverterParameter? “时间跨度”是什么意思? c# 的意思是什么? - what does “timespan?” mean in c#? TimeSpan.FromSeconds 给出指定参数的错误超出有效值范围。参数名称:间隔 - TimeSpan.FromSeconds gives error of Specified argument was out of the range of valid values.Parameter name: Interval 输入字符串的格式不正确。 在改变文化的IE中调用TimeSpan.FromSeconds(Convert.ToDouble(time)) - Input string was not in a correct format. calling TimeSpan.FromSeconds(Convert.ToDouble(time)) in IE on Changing Culture C#:当用作论坛的参数时,“所有者”是什么意思? - C#: What does 'owner' mean when used as argument of a class? T [,]在C#中意味着什么 - What would T[, ,] mean in C# WPF / C#上的名称比较是什么意思? - What does name comparison mean on WPF/C#? C#:Func &lt;&gt;用作方法的返回值是什么意思? - C#:What does Func<> mean when used as return value of a method? 加/减分钟C#时(2)个其他时间跨度之间的时间跨度 - Timespan between (2) other Timespan when adding / subtracting minutes C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM