string[] arr1 = {"廣州", "中國", "上海", "北京","中國"};
Dictionary<string ,int> d = new Dictionary<string,int>();
foreach (var item in arr1)
{
if (d.ContainsKey(item))
{
d[item]=d[item] + 1;
}
else
{
d.Add(item, 1);
}
}
string s = d.OrderByDescending(p=>p.Value).First().Key;
Console.WriteLine(s);
Console.ReadKey();
摘自 歐陽小燕