在哪里可以找到新的 Span<T>?
Where do I find the new Span<T>?
每个人都在谈论新类型 Span<T>
有多棒,所以我急切地想开始重写我的库中的几个方法,但实际上我在哪里可以找到它?我已将 Visual Studio 2017 更新到最新版本 15.5.0,其中更改日志显示:
The C# compiler now supports the 7.2 set of language features including:
- Support for the
Span<T>
type being used throughout Kestrel and CoreFX via the ref struct modifier.
但是当我尝试使用它时,我的代码出现错误,智能感知无法解决它。这是一个 .net 4.6.2 项目,语言版本设置为 latest minor.
我需要安装一些 NuGet 包才能使用它吗?我想不通。
您需要安装 System.Memory
包的预发布版本(选中 nuget 管理器中的 "Include prerelease" 复选框)。然后只需使用 Span
(它在 System
命名空间中)。
Visual Studio 2019:如果您使用的是完整的 .NET Framework(例如 4.7.2):
- 转到 NuGet 包管理器
- 搜索 System.Memory Microsoft 软件包并安装。
现在您将可以使用 Span<T>
。
无需再搜索预发布版本。
每个人都在谈论新类型 Span<T>
有多棒,所以我急切地想开始重写我的库中的几个方法,但实际上我在哪里可以找到它?我已将 Visual Studio 2017 更新到最新版本 15.5.0,其中更改日志显示:
The C# compiler now supports the 7.2 set of language features including:
- Support for the
Span<T>
type being used throughout Kestrel and CoreFX via the ref struct modifier.
但是当我尝试使用它时,我的代码出现错误,智能感知无法解决它。这是一个 .net 4.6.2 项目,语言版本设置为 latest minor.
我需要安装一些 NuGet 包才能使用它吗?我想不通。
您需要安装 System.Memory
包的预发布版本(选中 nuget 管理器中的 "Include prerelease" 复选框)。然后只需使用 Span
(它在 System
命名空间中)。
Visual Studio 2019:如果您使用的是完整的 .NET Framework(例如 4.7.2):
- 转到 NuGet 包管理器
- 搜索 System.Memory Microsoft 软件包并安装。
现在您将可以使用 Span<T>
。
无需再搜索预发布版本。