日期:2014-05-18 浏览次数:20774 次
using System.Linq; int[] arr = new int[10] { 1, 2, 3, 3, 4, 2, 4, 5, 7, 8 }; var vs = from i in arr group i by i into m select new { m.Key, num = m.Count() }; foreach (var v in vs) { MessageBox.Show(v.Key + "=" + v.num); }