class Car{
int ID {get;set;}
string Text {get;set;}
}
List<Car> allCars = new List<Car>(){ new Car{ ID = 1, Text = "one"}, new Car{ ID = 2, Text = "two"}, new Car{ ID = 3, Text = "three"}, new Car{ ID = 4, Text = "four"} };
int[] existingCarIds = new int[]{ 2, 4 };
I would like to have this list.
CarWithID2
CarWithID4
CarWithID1
CarWithID3
So I did:
List<Car> carList = allCars.Where(d => existingCarIds.Contains(d.ID)).Concat(allCars.Where(d => !existingCarIds.Contains(d.ID))).ToList();
Is there are any other way to do the same query?
Thanks
Lorenzo.