"sho_nuff" <sh*********@yahoo.com> wrote:
I have several DateTime objects and i want to
get the average of all of them.
What would be the easiest way to do this?
private static DateTime AverageDateTime(params DateTime[] dateTimes)
{
long[] lngTicks = new long[dateTimes.Length];
long lngTotal = 0;
// Convert all DateTimes to ticks
for (int i = 0; i < dateTimes.Length; i++)
{
lngTicks[i] = dateTimes[i].Ticks;
lngTotal += lngTicks[i];
}
// Return the average as a DateTime
return new DateTime(lngTotal / lngTicks.Length);
}
P.
--
www.CL4.org