【发布时间】:2016-10-23 16:35:39
【问题描述】:
下面的代码在使用 profile7 的 PCL 库中编译时可以正常编译(目标:.NET 4.5、Windows 8、.NET Core 1.0、Xamarin.Android、Xamarin.IOS、Xamarin.IOS Classic)
但是,在将 PCL 项目转换为 .NET Standard 1.3 库后,它会失败并显示:
error CS1061: 'IEnumerable<string>' does not contain a definition for 'AsParallel' and no extension method 'AsParallel' accepting a first argument of type 'IEnumerable<string>' could be found (are you missing a using directive or an assembly reference?)
但是 .NET Standard 1.3 应该仍然支持 PLINQ 的 AsParallel() 方法,对吧? 也许我忽略了什么?是否应该为 PLINQ 包含一个额外的 nuget?
using System.Collections.Generic;
using System.Linq;
namespace PclTest
{
public class Class1
{
public void Test()
{
List<string> list = new List<string> { "foo", "bar" };
var result = list.AsParallel().Where(x => x == "foo").ToList();
System.Diagnostics.Debug.Assert(result.Count == 1);
}
}
}
我正在使用带有所有最新更新的 Visual Studio 2015
【问题讨论】:
-
@LexLi 的意思是有一个
System.Linq.Parallel包。 -
Henk 的评论帮我解决了问题
标签: c# .net portable-class-library portability plinq