Well this is maybe a not the most elegant solution but it does the job:
public string GetMaxElementCount(string[] array)
{
List<string> list = new List<string>(array);
IEnumerable<IGrouping<string, string>> g = list.GroupBy(i => i);
int countMax = 0;
string keyMax = string.Empty;
foreach (IGrouping<string, string> grp in g)
{
int count = grp.Count();
if (countMax < count)
{
countMax = count;
keyMax = grp.Key;
}
}
return keyMax;
}
Cheers