DateTime Ticks,检查重叠日期C#

时间:2013-04-10 02:49:28

标签: c#

让我们说我渴望一个开始和结束,这实际上是两个日期时间转换为刻度。我怎么知道这两个值是否重叠?

1 个答案:

答案 0 :(得分:1)

正如MPelletier所说:你需要两对DateTimes:

var start1 = new DateTime(2013, 4, 10).Ticks;
var end1 = new DateTime(2013, 4, 20).Ticks;

var start2 = new DateTime(2013, 4, 9).Ticks;
var end2 = new DateTime(2013, 4, 11).Ticks;

if (start2 < end1)
{
    //// Overlapping
}