委托System.Func <testclass,tetsclassresult =“”>在最近的Xamarin更新

时间:2016-09-19 20:25:11

标签: xamarin xamarin-studio func

在最近的Xamarin Studio(Mac OS)更新后,我无法再使用Func<Arg1, TResult>类使用来构建我的PCL。由于某种原因,它开始抱怨这个功能不需要两个参数:

  

错误CS1593:委托System.Func<TestClass, TetsClassResult>   不要带2个参数(CS1593)(MyPclLib)

如果我创建一个新的测试项目 - 只需使用简化的func方法体就可以使用完全相同的代码:

public class MyClass
{
    public MyClass ()
    {
        var array = new TestClass [] { new TestClass(), new TestClass() };
        var any = array.Select<TestClass, TestClassResult> ((arg1, index) => {
            return new TestClassResult (index);
        });
    } 
}

public class TestClass
{
}

public class TestClassResult
{
    public TestClassResult(int index)
    {
         //...
    }
}

即使我简化了我的原始方法,它也开始工作了,所以我想在更新之后Xamarin Studio无法推断出args的使用情况,并且没有多少正确的Func&lt;&gt;上课,但我找不到如何帮助它找到它。

Xamarin Studio信息:

Xamarin Studio Enterprise
Version 6.1 (build 5441)
Installation UUID: e6dcef46-0a84-444e-bcfd-8be8b1a3b2b1
Runtime:
    Mono 4.6.0 (mono-4.6.0-branch/746756c) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 406000245

NuGet
Version: 3.4.3.0

Xamarin.Profiler
Not Installed

Apple Developer Tools
Xcode 8.0 (11246)
Build 8A218a

Xamarin.iOS
Version: 10.0.0.6 (Xamarin Enterprise)
Hash: 6c3fee4
Branch: xcode8
Build date: 2016-09-09 13:01:32-0400

Xamarin.Android
Version: 7.0.0.18 (Xamarin Enterprise)
Android SDK: /Users/username/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        4.0.3  (API level 15)
        4.1    (API level 16)
        4.2    (API level 17)
        4.3    (API level 18)
        4.4    (API level 19)
        4.4.87 (API level 20)
        5.0    (API level 21)
        5.1    (API level 22)
        6.0    (API level 23)
        7.0    (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 24.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin Android Player
Not Installed

Xamarin.Mac
Version: 2.10.0.99 (Xamarin Enterprise)

Build Information
Release ID: 601005441
Git revision: 68292d1ab289911c815ddc715dd7cc29a9752f9f
Build date: 2016-09-09 04:43:23-04
Xamarin addins: ed25d008672663eeb9db55f1ccecb3c24d2fd3b2
Build lane: monodevelop-lion-cycle8

1 个答案:

答案 0 :(得分:1)

尝试这种方法

var any = array.Select((testClass) => {
             return new TestClassResult (array.IndexOf(testClass));
          });