c# - .Net 3.5 VS 2008 无效 token 'out' 错误

标签 c# .net .net-3.5 token sharpmap

我正在尝试编译 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不是来自任何地方;它是泛型类型参数。相比之下,它是 TList<T> ;它是调用者希望它成为的任何东西。如果来电者引用 ISpatialIndexItem<int> , 然后 TOidint .

关于c# - .Net 3.5 VS 2008 无效 token 'out' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51092676/

相关文章:

c# - 您可以在不需要集成测试的情况下自行测试 razor View 吗?

c# - 如何修改 visual studio 中绿色开始按钮的作用?

javascript - 由 MVC 呈现的对话框(弹出窗口) Bootstrap

c# - 匿名类型与动态类型

C# 不明确的调用 - 不同的返回类型

c# - 如何用另一个 DocumentText 更新 DocumentText

c# - 同一类上的两组序列化属性

c# - 在 C# 中杀死一个进程

c# - WPF C# 项目的 sql server 登录失败

c# - 网格控制