I am trying to remove duplicates when merging two lists of objects (vehicles) using LINQ , for example:
var list = list1.Union(list2);
I have an overridden the Equal method and the code will not even go into it. However, this code takes a step in redefinition:
Vehicle v1 = new Vehicle(); Vehicle v2 = new Vehicle(); if (v1.Equals(v2)).......
EDIT
Signatures for redefining vehicles are given here:
I also implement IEquatable<Vehicle>
public bool Equals(Vehicle other) { } public override int GetHashCode() { }
I would prefer not to pass a comparison with the Union method, since I want thelogic in the Vehicle class.
What have I done wrong here?
c # linq
davy
source share