List<int> L = new List<int>(){1,2,3,4,5,6,7,8,9,1,6,9}; // return 1 6 9
//我想从L 中返回 元素出现次数不为1(即元素出现次数>1) 的元素到列表,如何使用Linq ?
//我想从L 中返回 元素出现次数不为1(即元素出现次数>1) 的元素到列表,如何使用Linq ?
解决方案 »
- c# 封送结构体 变长数组的定义问题
- winform中组合控件如何设置RadioButton的组
- sql产生一列连续数字
- 很急,请大家一起帮个忙.关于使用sqlhelper.CS中方法的问题(三层架构并结合WEBSERVICE)
- 如何在c#winform中调用带输入参数的存储过程 - 代码已贴出 谢谢!!
- XP home edtion版本的操作系统能够装.net吗?我在windows组件找不到IIS!
- 请教一个读取数据的性能问题
- 实现一个字串特效显示控件,闪个不停怎么办???
- 如何用AT指令判断短信已经成功发送并且已经成功到达对方,如何设置对方接收到短信的自动回复功能?
- 请问在ado.net中怎么锁定数据库的悲观锁定?
- 代码哪里错拉
- 一个生成程序时的错误
var q = from x in ary
group x by x into Y where Y.Count()>1
select {Y.Key,Y.Count()};
var q = from x in ary
group x by x into Y
where Y.Count() > 1
select Y.Key;
foreach (var p in q)
{
Console.WriteLine(p);
}
比如:L.Select(a => ...我不会写
int[] result = ary.Where(x => ary.Where(y => y == x).Count() > 1).ToArray();
int[] result = ary.Where(x => ary.Where(y => y == x).Count() > 1).Distinct().ToArray();
List<int> L = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 6, 9 };
var q2 = from a in L
group L by a into b
where b.Count() > 1
select b;
int[] result = ary.GroupBy(i => i).Where(y => y.Count() > 1).Select(g => g.Key).ToArray();
//List<int> L = V.Where(a => a.Count() != 1).Select(b => b.Key).ToList(); //List<int> L = (from cp in ((frmMain)this.Owner).SsqCp select cp.QiAc).ToList();
//L = L.GroupBy(a => a).Where(a => a.Count() > 1).Select(c => c.Key).Distinct().ToList();
//L.Sort(); List<int> L = (from cp in ((frmMain)this.Owner).SsqCp select cp.QiAc).ToList();
L = (from a in L group a by a into g where g.Count() > 1 select g.Key).ToList();
L.Sort(); int n = 0;
foreach (int item in L)
{
n = n + 1;
Console.WriteLine(n + " " + item);
}