static string SelectPopularDelimiter(List <string> delimiters) { List <GroupString> delimiterGroups = getGroupsString(delimiters); GroupString mostPopularDelimiter = delimiterGroups.MaxBy(t => t.Count); return(mostPopularDelimiter.Value); }
static List <GroupString> getGroupsString(List <string> list) { var numberGroups = list.GroupBy(i => i); List <GroupString> groups = new List <GroupString>(); foreach (var grp in numberGroups) { GroupString group = new GroupString(); group.Value = grp.Key; group.Count = grp.Count(); groups.Add(group); } return(groups); }