I got some code from a friend of mine and it works great in a windows. forms application. When I try to use the same Code in a Xamarin.Forms project, it says:
System.Collections.Generic.List>' has no definition for 'ForEach'. [...] (maybe a "using" is missing) (translated from german))
I have:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Xamarin.Forms;
using System.Reflection;
Here is the Code that gives the error:
public Company GetCompanyById(int companyId) {
Company company = new Company();
allContinents
.MyContinents
.Select(x => x.Countries)
.ToList()
.ForEach(countryList => {
countryList.ForEach(country => {
country.Cities.ForEach(city => {
city.Companies.ForEach(com => {
if (com.Id.Equals(companyId))
company = com;
});
});
});
});
return company;
}
Why doesn't it work as is does in a windows.forms app? ps: it's the first ForEach with is underlined in blue
Thanks