using System.Collections;
using System.Collections.Generic;
public static void Main()
List<ItemDetails> theTempList = new List<ItemDetails>();
List<ItemDetails> theOriList = new List<ItemDetails>();
DateTime minDate = new DateTime(2016, 1, 1);
DateTime maxDate = new DateTime(2016, 1, 1);
theOriList.Add(new ItemDetails("S1","S2", new DateTime(2016,1,1), new DateTime(2016,1,15)));
theOriList.Add(new ItemDetails("S2", "S3", new DateTime(2016, 2, 1), new DateTime(2016, 2, 14)));
theOriList.Add(new ItemDetails("S1", "S2", new DateTime(2016, 1, 5), new DateTime(2016, 1, 20)));
theOriList.Add(new ItemDetails("S2", "S3", new DateTime(2016, 1, 25), new DateTime(2016, 2, 25)));
theOriList.Add(new ItemDetails("S1", "S2", new DateTime(2016, 1, 21), new DateTime(2016, 1, 25)));
theOriList.GroupBy(x=> new {x.From, x.To })
.Select(x=> new ItemDetails(x.Key.From,x.Key.To,x.Min(m=>m.FromDate), x.Max(m=>m.ToDate)))
public DateTime FromDate;
public ItemDetails(string from1, string to, DateTime fromDate, DateTime toDate)