LINQ to remove objects from a list of objects based on another list of
objects
public class Car
{
private string _manufacturer = string.empty;
private string _color = string.empty;
private string _modelLine= string.empty;
public string Manufacturer
{
get { return _manufacturer; }
set { _manufacturer= value; }
}
public string Color
{
get { return _color; }
set { _color= value; }
}
public string ModelLine
{
get { return _modelLine; }
set { _modelLine= value; }
}
}
I have a List allCars, and I want to remove from the list all items that
are in a second list List selectedCars. How can I accomplish this with
LINQ?
I tried something similiar to:
List<Car> listResults = allCars.Except(selectedCars).ToList();
However it is not removing any items from the allCars list.
No comments:
Post a Comment