```
public IList<Interval> Merge(IList<Interval> intervals) {
var result = new List<Interval>();
if(intervals == null || intervals.Count == 0)
return result;
intervals = intervals.OrderBy(o => o.start).ToList();
Interval current = intervals[0];
for(int i = 1; i < intervals.Count; i++)
{
if(current.start <= intervals[i].end && intervals[i].start <= current.end)
current.end = Math.Max(current.end, intervals[i].end);
else
{
result.Add(current);
current = intervals[i];
}
}
result.Add(current);
return result;
}
```