I've got a for loop using a DateTime, I'm trying to add points to a chart by summing the data; however, when running the loop I get this error:
InvalidCastException was unhandled: Invalid cast from 'DateTime' to 'Int32'.
Here is the code in the for loop I am trying:
List<Series> dataSeries = chartDailyCost.Series.ToList();
for (DateTime i = Convert.ToDateTime("00:00"); 
              i <= (Convert.ToDateTime("23:45")); 
              i = i.AddMinutes(15))
{
    double sum = 0d;
    //for every series in the chart collection sum the yvalues at the specified 
    foreach (Series s in dataSeries)
    {
        //This is the line I am getting the error for
        sum += s.Points[Convert.ToInt32(i)].YValues[0];
    }
    DataPoint dp = new DataPoint();
    //Add a new yvalue to the datapoint for the summed series's
    //And I will get an error in this one as well
    dp.XValue = dataSeries[0].Points[Convert.ToInt32(i)].XValue;
    dp.YValues[0] = sum;
    sumSeries.Points.Add(dp);
}
 
    