我从我的一个朋友那里得到了一些代码,它在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
谢谢
我尝试在我的xamarin.forms项目中包含.csv文件.问题是,我认为当我将该文件用作嵌入式资源时,它只能立即用于所有平台.我的程序集只有三种方法:
Equals()
Load()
ReferenceEquals()
Run Code Online (Sandbox Code Playgroud)
但我需要Assembly.GetExecutingAssembly()让我的代码工作.
你知道怎么解决这个问题吗?或者可能是替代方案?顺便说一句:我使用Visual Studio 2013 Ultimate和Xamarin.Android/iOS的试用许可证
编辑:我想它必须做某事.与Xamarin.Forms.一个普通的桌面应用程序有Assembly.GetExecutingAssembly(); 它工作正常,但我需要它在我的应用程序:(
编辑2:我现在试试这个:http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/files/#Loading_Files_Embedded_as_Resources