I have the following model classes. I want to retrieve object of AddressMatch from AddressMatches list based on some condition.
public class AddressMatchList
{
public List<AddressMatch> AddressMatches { get; set; }
}
public class AddressMatch
{
public string HouseRange { get; set; }
public string HouseNumber { get; set; }
public string StreetName { get; set; }
public string AddressIdentifier { get; set; }
}
I tried this:
AddressMatch selectedMatchedAddress = new AddressMatch();
selectedMatchedAddress = addressMatches.AddressMatches.Where(a => a.AddressIdentifier == "cpr");
But got error:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'AddressMatch'. An explicit conversion exists (are you missing a cast?)