我正在尝试编译 SharpMap对于 .Net 3.5,我已经解决了大部分错误,目前我遇到的唯一错误是:
Invalid token 'out' in class, struct, or interface member declaration
Invalid token '>' in class, struct, or interface member declaration
Type expected
错误位于 this file 的开头(第 36 行) .这是代码(第一行有错误)。
public interface ISpatialIndexItem<out TOid>
{
/// <summary>
/// Gets the object's identifier
/// </summary>
TOid ID { get; }
/// <summary>
/// Gets the spatial extent of the object
/// </summary>
Envelope Box { get; }
}
此外,我无法找出什么是 TOid 以及它来自哪个库。 我正在使用 VS 2008 .Net 3.5,由于我正在处理的项目的具体情况,我无法升级。
最佳答案
协变和逆变泛型类型参数(out
)在 .NET 4.0 和 C# 4 中是新增的,因此您不能使用它。您可以删除 out
,但是其他一些部分可能会拒绝工作:/没有一个简单的解决方法,除了手动转换。
TOid
不是来自任何地方;它是泛型类型参数。相比之下,它是 T
在 List<T>
;它是调用者希望它成为的任何东西。如果来电者引用 ISpatialIndexItem<int>
, 然后 TOid
是int
.
关于c# - .Net 3.5 VS 2008 无效 token 'out' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51092676/