using System; using System.Linq; using System.Collections.Generic; class Channel { public String Name { get; set; } public TimeSpan Durarion { get; set; } } public class Test { public static void Main() { var array = new[]{ "Channel 1, 01:05:36", "Channel 2, 02:25:36", "Group 1, 22:25:36", "Network, 41:40:09", "Loss of, 03:21:17", "Loss of, 01:13:28", "Channel 1, 04:25:36", "Channel 2, 00:25:36", }; var channelGroups = array.Select(s => { var tokens = s.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); return new Channel() { Name = tokens[0], Durarion = new TimeSpan( int.Parse(tokens[1].Split(':')[0]), // hours int.Parse(tokens[1].Split(':')[1]), // minutes int.Parse(tokens[1].Split(':')[2])) // seconds }; }) .GroupBy(c => c.Name) .Select(g => new { Channel = g.Key, Count = g.Count(), Average = g.Average(c => c.Durarion.TotalMinutes) }); foreach(var group in channelGroups) { Console.WriteLine("Channel:[{0}] Count:[{1}] Average:[{2}]" ,group.Channel,group.Count,group.Average); } } }