更新时间:2023-11-28 21:42:28
尚不清楚您所说的大于startHour是什么意思...但是
It's not at all clear what you mean by "is greater than startHour"... but taking
TimeSpan startHour = new TimeSpan(12, 25, 43);
if (endHour.TimeOfDay > startHour)
{
...
}
...的工作非常简单。
... works pretty simply.
总而言之,请添加参数检查以确保您未为startHour指定值<
0或>
23小时,但这很容易。
By all means add argument checking to make sure that you don't specify a value for startHour which is <
0 or >
23 hours, but that's all pretty easy.
.NET的日期和时间API与Joda Time相比是相当原始的(即使在3.5中)-但在这种特殊情况下,我认为还不错。
.NET's date and time API is quite primitive (even in 3.5) compared with, say, Joda Time - but in this particular case I think it's not too bad.