Hi there
How to read a Temperature for August and get the total Aveg just for 29 day instead 31 day ?
i want to get the Aveg Temperature of August which has 31 day but sometime there is a data of temp just for 29 or 27 however how could i get the Avag based on how many days has been read and saved as data that could be (29,27,26 or 10 days) ?
here is the code :
- public static TheWeather GetAverageForMonth(List<TheWeather> entries, int year, int month)
- {
- if (entries == null || entries.Count < 1)
- return null;
- int days = 0;
- int index = entries.Count();
- double total = 0.0;
- double Aveg = 0.0;
- for (index = 0; index < entries.Count; index++)
- {
- if (entries[index].dateTime.Year == year && entries[index].dateTime.Month == month)
- {
- total += entries[index].Actual_mean_temp;
- days = entries[index].dateTime.Day;
- }
- }
- Aveg = total / days;
- return entries[index];