【发布时间】:2013-06-13 14:20:17
【问题描述】:
我正在创建一个可移植类库 (PCL) 并尝试使用 List.Exists() 和 List.TrueForAll(),但有人告诉我 System.Collections.Generic.List 不包含Exists 或 TrueForAll。我正在创建的 PCL 可以跨 .Net 4.5、Silverlight 4、Windows Phone 7.5、Mono Android 和 Mono iOS 工作。有什么我遗漏的吗?
注意:此代码适用于我制作的 .Net 4.0 库。
返回错误的代码示例:
List<object> set0;
List<object> set1;
if (set0.TrueForAll(obj0 => set1.Exists(obj1 => obj0.Equals(obj1))))
return true;
if(!(set0.Exists(obj0 => !set1.Exists(obj1 => obj0.Equals(obj1)))))
return true;
收到的错误:
错误:“System.Collections.Generic.List”不包含 'Exists' 的定义并且没有扩展方法 'Exists' 接受 'System.Collections.Generic.List' 类型的第一个参数 可以找到(您是否缺少 using 指令或程序集 参考?)
错误:“System.Collections.Generic.List”不包含 'TrueForAll' 的定义并且没有扩展方法'TrueForAll' 接受类型的第一个参数 'System.Collections.Generic.List' 可以找到(你是 缺少 using 指令或程序集引用?)
【问题讨论】:
-
它们应该很容易被 Linq 的 All 和 Any 替换
-
This documentation 声称(在版本信息下)该方法支持:可移植类库。
-
我找到了这份文档,其中包含可以访问PLIB APIs 的库。我对这个列表完全不了解吗?
标签: c# .net-4.5 xamarin portable-class-library