I have a method:
public List<AxeResult> LoadAxes(string kilometriczone, string axe)
{
IEnumerable<AxeResult> allAxes = PullAxes();
var findAxes = allAxes.Select(a => a.KilometricZone.StartsWith(kilometriczone) || a.KilometricZone.StartsWith(axe));
return findAxes.Cast<AxeResult>().ToList();
}
I have this error:
IEnumerable<bool>does not contain a definition forToListand the best extension method overloadEnumerable.ToList<AxeResult>(IEnumerable<AxeResult>) requires a receptor typeIEnumerable<AxeResult>
I want to return a List of AxeResult after the search operation.
What you want is to filter the collection. That's what Enumerable.Where is for:
public List<AxeResult> LoadAxes(string kilometriczone, string axe)
{
return PullAxes()
.Where(a => a.KilometricZone.StartsWith(kilometriczone) ||
a.KilometricZone.StartsWith(axe))
.ToList();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With