我从我的一个朋友那里得到了一些代码,它在windows中运行得很好.表格申请.当我尝试在Xamarin.Forms项目中使用相同的代码时,它说:
System.Collections.Generic.List>'没有'ForEach'的定义.[...](可能缺少"使用")(翻译自德语))
我有:
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;
Run Code Online (Sandbox Code Playgroud)
以下是给出错误的代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
为什么它不像windows.forms应用程序那样工作?ps:这是第一个以蓝色加下划线的ForEach
谢谢