public void setWeeks(){stDate = new DateTime();enDate = new DateTime();DateTime[] dateArray = new DateTime[50];endOfWeekDates = new DateTime();sevenDays = new TimeSpan(7, 0, 0, 0); // represents 7 daysendWeeksList = new ArrayList(1);stDate = System.DateTime.Parse(startDate); // convert string date to System.DateTime representationenDate = System.DateTime.Parse(endDate);//endOfWeekDates = stDate.Add(sevenDays);for (int i = 0; i < dateArray.Length; i++){if (dateArray[i].Add(sevenDays) < enDate){endWeeksList.Add(dateArray[i]);}else if (dateArray[i].Add(sevenDays) == enDate) // if same date add to list{endOfWeekDates = enDate;endWeeksList.Add(dateArray[i]);}else if (dateArray[i].Add(sevenDays) > enDate) // if over the end date add to list{endOfWeekDates = enDate;endWeeksList.Add(dateArray[i]);}MessageBox.Show("Dates are " + endWeeksList.ToString());}