I have the following class:
public class Membership
{
public DateTime StartDate { get; set; }
public DateTime? EndDate { get; set; } // If null then
So if I understand this correctly - you want to make sure date range 2 is not within date range 1?
For example:
startDate1 = 01/01/2011
endDate1 = 01/02/2011
and
startDate2 = 19/01/2011
endDate2 = 10/02/2011
This should be a simple case of:
if ((startDate2 >= startDate1 && startDate2 <= endDate1) ||
(endDate2 >= startDate1 && endDate2 <= endDate1))