如何计算给定列表的平均值,其内容如下所述:
06:56 06:58 06:55 06:54 06:54 06:53 06:55 06:53 06:58 06:54 06:58 06:55 06:54 06:50 06:54 06:57
任何的想法 ?!?
var times = new List{ "06:56", "06:58", "06:55", "06:54", "06:54", "06:53", "06:55", "06:53", "06:58", "06:54", "06:58", "06:55", "06:54", "06:50", "06:54", "06:57" }; var average = times .Select(TimeSpan.Parse) .Average(x => x.TotalMilliseconds); var averageTime = TimeSpan.FromMilliseconds(average);