- 积分
- 7540
- 明经币
- 个
- 注册时间
- 2006-4-6
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
- class TextEntList
- {
- public string Ent { get; set; }
- public string Text { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- ArrayList textents = new ArrayList();
- textents.Add(new TextEntList { Text = "L1", Ent = "e1", });
- textents.Add(new TextEntList { Text = "L11", Ent = "e2", });
- textents.Add(new TextEntList { Text = "L12", Ent = "e3", });
- textents.Add(new TextEntList { Text = "L1", Ent = "e4", });
- textents.Add(new TextEntList { Text = "L22", Ent = "e5", });
- textents.Add(new TextEntList { Text = "L12", Ent = "e6", });
- textents.Add(new TextEntList { Text = "L2", Ent = "e7", });
- var query =
- from TextEntList x in textents
- group x by x.Text into g
- select new { g.Key, N = g.Count() };
- foreach (var item in query)
- {
- Console.WriteLine(item);
- }
- Console.Write("Program finished, press Enter/Return to continue:");
- Console.ReadLine();
- }
- }
如果想要获得的结果:
{ Text = "L1" { Ent = "e1", Ent = "e4"}}。。。。 要怎么写,绕不弯来。。。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|