【发布时间】:2023-03-03 03:35:01
【问题描述】:
我有以下 sn-p 代码来测试/使用 vs 2017 中的 dotnet 2.1,以便尝试和运行 C# 7.2s Span 功能。 在哪里可以找到允许我在 Visual Studio 中运行它的 SDK。 我只能找到最高 2.0 的框架。
using System;
using System.Memory;
namespace sim
{
class Program
{
static void Main(string[] args)
{
var arr = new byte[10];
Span<byte> bytes = arr; // Implicit cast from T[] to Span<T>
Span<byte> slicedBytes = bytes.Slice(start: 5, length: 2);
}
}
}
否则我将无法运行和使用 错误 CS0305 使用泛型类型“内存”需要 1 个类型参数 sim
【问题讨论】:
-
.NET Core 2.1 仍处于预览阶段:github.com/dotnet/core/blob/master/roadmap.md
-
但是有 VS2017 预览版大概可以与 2.1 版预览版一起使用:visualstudio.com/vs/preview
标签: c# visual-studio-2017 .net-core c#-7.2