Filter a list of address objects by a list of string postcodes

51 Views Asked by At

I have a list of address objects which is used as a data source on a pivot grid. What I have to do is be able to filter the list down based on a list of postcodes.

So, lets say I have 100 address objects in the list (Simple object with Address1, Address2 and PostCode properties).

List<Address> addresses = _pivotGrid.DataSource;

I have a second list of strings which contain abbreviated postcodes - EG. ML4 3GH is abbreviated to ML4, EH1 3QH is abbreviated to EH1 and so on.

List<string> postCodes

I want the original list to filter down so it only shows those postcodes that begin with ML4 and EH1 and so on.

Can this be done via Linq?

0

There are 0 best solutions below