I have a list in C#:
var list = new List();
list.AddRange(GetGreenCars());
list.AddRange(GetBigCars());
list.AddRange(
Given you override the .Equals()
method for Car
to determine one car object is the same as another car object, then the following should work w/o writing an extension method.
var list = new List();
list.AddRange(GetGreenCars()?.Except(list) ?? new List());
list.AddRange(GetBigCars()?.Except(list) ?? new List());
list.AddRange(GetSmallCars()?.Except(list) ?? new List());