title: Check if date range is sequential in c#?
body: <p>Assume I have a user interface where the user can select days.  Is there a way to check if the days selected are sequential, such as:</p>
  
  <p>4/4, 4/5, 4/6, 4/7, 4/8, 4/9, 4/10 or</p>
  
  <p>4/29, 4/30, 5/1, 5/2, 5/3</p>
  
  <p>I know I probably can loop through the date range and check, but I was more curious if there was a built in method already to check for this.</p>
  
  <p>Regarding the above scenarios, they are in order and they can roll over into the next month.</p>
  
  <p>I am using the .NET Framework 2.0 and can't use LINQ.</p>
  
  <p>Regarding Tom's answer:</p>
  
  <pre><code>DateTime dtStart = new DateTime(2011,5,4);
  DateTime dtEnd = new DateTime(2011,5,11);
  
  int numberOfDaysSelected = 7; //Assume 7 days were selected.
  
  TimeSpan ts = dtEnd - dtStart;
  
  
  if(ts.Days == numberOfDaysSelected - 1)
  {
  Console.WriteLine("Sequential");
  }
  else
  {
  Console.WriteLine("Non-Sequential");
  }
  </code></pre>