现有如下需求,要求统计int数组中每个整数的个数:

int[] arrInt = {1,2,3,4,5,6,1,2,3,4,1,2,3 };
            var linq = from item in arrInt
                       group item by item into g//注意这里的into g,这里必须为g 表示范围变量IGrouping<int,int> 
                       select new {key=g.Key,value=g.Count() };//这里选择了整数的值为key,个数为值的匿名对象

 

相关文章:

  • 2021-08-21
  • 2021-12-16
  • 2021-10-22
  • 2022-12-23
  • 2021-07-14
  • 2021-11-03
  • 2021-08-14
猜你喜欢
  • 2021-07-24
  • 2021-06-21
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案