第1个回答 2013-09-22
using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace ConsoleApplication1{ class Program { static void Main(string[] args) { List<String> record = new List<String>() { "Hello","World","This","is","my","first","try","to","say","Hello" };
var query = from r in record group r by r.ToLower() into g select new { Count = g.Count(), Value = g.Key };
foreach (var v in query) { Console.WriteLine("Value = {0}, Count = {1}", v.Value, v.Count); } } }}使用LINQ TO OBJECT,一句话就搞定了