using System.Collections;
using System.Collections.Generic;
public static void Main()
var startDate = new DateTime(2015, 7, 1);
var endDate = new DateTime(2015, 9, 1);
var workDates = Enumerable.Range(0, (int)(endDate - startDate).TotalDays + 1)
.Select(i => startDate.AddDays(i))
.Where(date => (date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday))
.GroupAdjacentBy((x, y) => x.AddDays(1) == y)
.Select(g => string.Format("Start: {0:dd/MMM/yyyy} End: {1:dd/MMM/yyy}", g.First(), g.Last()));
foreach (var displayString in display)
Console.WriteLine(displayString);
public static class IEnumerableExtension
public static IEnumerable<IEnumerable<T>> GroupAdjacentBy<T>(
this IEnumerable<T> source, Func<T, T, bool> predicate)
using (var e = source.GetEnumerator())
var list = new List<T> { e.Current };
if (predicate(pred, e.Current))
list = new List<T> { e.Current };