int [] n=new int[10]{2,3,33,33,55,55,123,33,88,234};
output=2,3,123,88,234;
使用LINQ 我可以通过不断检查来使用两个for循环来完成它。但是我需要一种更简单的方式使用LINQ
它不会删除重复项.. 通过distinct删除重复项将给出 = 2,3,123,33,55,88,234 我的输出应该是 = 2,3,123,,88,234;
int [] n=new int[10]{2,3,33,33,55,55,123,33,88,234};
output=2,3,123,88,234;
使用LINQ 我可以通过不断检查来使用两个for循环来完成它。但是我需要一种更简单的方式使用LINQ
它不会删除重复项.. 通过distinct删除重复项将给出 = 2,3,123,33,55,88,234 我的输出应该是 = 2,3,123,,88,234;
我结合了你的分组想法和matiash的计数,不确定它的速度如何。
var result = n.GroupBy(s => s).Where(g => g.Count() == 1).Select(g => g.Key);
更新:我已经测量了速度,看起来时间是线性的,因此您可以将其用于大型集合
var result = n.Where(d => n.Count(d1 => d1 == d) <= 1);