Start here:
How to: Find the Set Difference Between Two Lists (LINQ)[
^]
For example:
Class definition
public class Point
{
private int x = 0;
private int y = 0;
public Point()
{
}
public Point(int _x, int _y)
{
x = _x;
y = _y;
}
public int X
{
get { return x; }
set { x = value; }
}
public int Y
{
get { return y; }
set { y = value; }
}
public override bool Equals(Object obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
Point p = (Point)obj;
return (x == p.x) && (y == p.y);
}
public override int GetHashCode()
{
return x ^ y;
}
}
Usage:
void Main()
{
List<Point> pointsA = new List<Point>();
pointsA.Add(new Point(5,5));
pointsA.Add(new Point(10,8));
List<Point> pointsB = new List<Point>();
pointsB.Add(new Point(5,5));
pointsB.Add(new Point(9,8));
var result = pointsA.Union(pointsB)
.Except(
pointsA.Intersect(pointsB)
);
}
Result:
X Y
10 8
9 8
As you can see, a result list contains unique points.