Getting Overlapping Start and End Date

前端 未结 4 1492
情书的邮戳
情书的邮戳 2021-01-28 09:13

Given a DateRange I need to return a list of Start and EndDates that overlaps the given period.

what is the best way to do it? Thanks for your time in advance.

4条回答
  •  独厮守ぢ
    2021-01-28 10:07

    this piece of LINQ might help:

    var overlappedPeriods = bookedPeriods.Where(p=>p.EndDate > startDate && p.StartDate < endDate);
    

    then transform the results accordingly to your OverlappedPeriod class

提交回复
热议问题