Now the only conflict left is when two endDates (10,15 in code) min value comes against the same startDate(25).
solution: I want to take min value out among those two min. values given by conflicting endDate.
public class DateController : Controller
public ActionResult date()
{
int allDiff;
List<int> list=new List<int>();
int flag = 0;
DateTime[] startDate = new DateTime[3];
startDate[0] = new DateTime(2011, 11, 5);
startDate[1] = new DateTime(2011, 11, 7);
startDate[2] = new DateTime(2011, 11, 25);
DateTime[] endDate = new DateTime[3];
endDate[0] = new DateTime(2011, 11, 10);
endDate[1] = new DateTime(2011, 11,15);
endDate[2] = new DateTime(2011, 11, 30);
DateTime Min= startDate.Min();
DateTime Max = endDate.Max();
TimeSpan span = Max - Min;
int total = span.Days;
ViewBag.globalTotal = total;
foreach (DateTime e in endDate)
{
foreach (DateTime s in startDate)
{
if (s >= e)
{
TimeSpan span1 = s - e;
allDiff = span1.Days;
list.Add(allDiff);
flag = 1;
}
else {
flag = 0;
}
}
if (flag == 1)
{
int m = list.Min();
ViewBag.dhiraj = m;
total = total - m;
list.Clear();
}
}
ViewBag.Total = total;
return View();
}
Working code