public static char SelectPopularSeparator(List <char> separators) { List <GroupChar> separatorGroups = getGroupsChar(separators); GroupChar mostPopularSeparator = separatorGroups.MaxBy(t => t.Count); return(mostPopularSeparator.Key); }
static List <GroupChar> getGroupsChar(List <char> list) { var numberGroups = list.GroupBy(i => i); List <GroupChar> groups = new List <GroupChar>(); foreach (var grp in numberGroups) { GroupChar group = new GroupChar(); group.Key = grp.Key; group.Count = grp.Count(); groups.Add(group); } return(groups); }