码迷,mamicode.com
首页 > 其他好文 > 详细

linq分组查询

时间:2015-01-05 00:26:21      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

string[] arrStr = { ".com", "www.baidu.com", "www.qq.com", "www.bing.cn", "www.avc.net","www.vvv.cn","www.bbb.net" };
           

//定义查询规则

var addressG = from gg in arrStr
                           where gg.LastIndexOf(".") != -1
                           group gg by gg.Substring(gg.LastIndexOf("."));
           

//执行查询

//迭代每一组

foreach (var grp in addressG)
            {

//迭代每组里的值
                foreach (var item in grp)
                {
                    Console.WriteLine(grp.Key+":"+item);
                }
            }

linq分组查询

标签:

原文地址:http://www.cnblogs.com/mingjian/p/4202498.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!