I have this view model that is List contain startdate and End date I want change this range list to other that if difference between next start and end date is 1 merge this range to each other for example
2024/03/21-2024/03/22
2024/03/23-2024/03/25
2024/03/26-2024/03/28
2024/04/01-2024/04/02
so I want change to this range
2024/03/21-2024/03/28
2024/04/01-2024/04/01
my code run time is slowly
var count = datas.Count();
for (int i = 0; i < count; i++)
{
TimeSpan def =(datas[i + 1].StartDate-datas[i].EndDate);
int diff = int.Parse(def.ToString());
if ((int)diff == 1)
datas[i].EndDate=datas[i + 1].EndDate;
}