相关疑难解决方法(0)

C#LINQ在List中查找重复项

使用LINQ,从a List<int>,如何检索包含重复多次的条目及其值的列表?

linq list duplicate-removal

293
推荐指数
6
解决办法
23万
查看次数

获取在列表中两次出现exaclty的对象列表

我有一个List<CustomPoint> points;包含近百万个对象的东西.从这个列表中我想得到恰好发生两次的对象列表.最快的方法是什么?我也会对非Linq选项感兴趣,因为我可能也必须在C++中这样做.

public class CustomPoint
{
    public double X { get; set; }
    public double Y { get; set; }

    public CustomPoint(double x, double y)
    {
        this.X = x;
        this.Y = y;
    }
}

public class PointComparer : IEqualityComparer<CustomPoint>
{
    public bool Equals(CustomPoint x, CustomPoint y)
    {
        return ((x.X == y.X) && (y.Y == x.Y));
    }

    public int GetHashCode(CustomPoint obj)
    {
        int hash = 0;
        hash ^= obj.X.GetHashCode();
        hash ^= obj.Y.GetHashCode();
        return hash;
    }
}
Run Code Online (Sandbox Code Playgroud)

基于这个答案,我试过, …

c# duplicates

11
推荐指数
2
解决办法
704
查看次数

标签 统计

c# ×1

duplicate-removal ×1

duplicates ×1

linq ×1

list ×1