简体   繁体   中英

public interface differences between vs2008 and vs2010?

I just created a simple project in VS2010, C# dotnet 3.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Business.Util
{
        public interface ICalculateCurrent<in T1, in T2, in T3, in T4>
        {
            bool GetValue(T1 obj1, T2 obj2, T3 obj3, T4 obj4);
        }

        public static class test
        {
            static void Main(string[] args)
            {

            }
        }
}

Fine, doesn't do anything at the moment but it compiles.

Then realizing that I really wanted to be doing this in VS2008, dotnet3.5 I created the exact same code and I get nothing but errors regarding the interface;

Invalid token 'in' in class, struct, or interface member declaration
Type expected
Invalid token ',' in class, struct, or interface member declaration
Invalid token ',' in class, struct, or interface member declaration
Invalid token ',' in class, struct, or interface member declaration
Invalid token '>' in class, struct, or interface member declaration

The project references are both the same. What am I missing on this?

thanks.

Variant interfaces require the VS2010 version of the C# compiler. Even though you're targeting .NET 3.5, it was still using the new compiler.

No way to do this with VS2008, sorry. .NET 3.5 includes runtime support for variant interfaces but the older C# compiler doesn't.

If you aren't using interface variance, just remove in all four times it appears on that line.

The in keyword for generics was added to VS10. Read here .

outin关键字以及因此的协变量和反变量泛型类型参数是C#4.0的新增功能(随VS 2010提供)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM