Intersects
Returns true if two date ranges intersect.
Source
public static class DateTimeExtensions
{
public static bool Intersects(this DateTime startDate, DateTime endDate, DateTime intersectingStartDate, DateTime intersectingEndDate)
{
return (intersectingEndDate >= startDate && intersectingStartDate <= endDate);
}
}
Example
bool eventsInterect = eventXStartDate.Intersects(eventXEndDate, eventYStartDate, eventYEndDate);