How can i filter a list of objects using lamda expression?
- by Colour Blend
I know i shouldn't have id's with the same value. This is just fictitious, so overlook that.
I have:
List<Car> carList = new List<Car>();
carList.Add(new Car() { id = 1, name = "Honda" });
carList.Add(new Car() { id = 2, name = "Toyota" });
carList.Add(new Car() { id = 1, name = "Nissan" });
I want to use Lamda Expression to retreive all cars that have an id of 1.
Anticipated Result:
-- Id: 1, Name: Honda
-- Id: 1, Name: Nissan
The problem is more filtering an object list based on a foriegn key. Please help me.