gpt4 book ai didi

c# - 如何为 csi.exe 设置 C# 版本

转载 作者:行者123 更新时间:2023-12-04 04:14:46 26 4
gpt4 key购买 nike

在 C# 交互式(作为 Visual Studio 2019 或独立的一部分)中,我想使用 C# 编写类似的代码:

var s = "abcdef";
var s1 = s[2..4];

这给出了以下消息:

(1,12): error CS0518: Predefined type 'System.Range' is not defined or imported



有没有办法修改例如 csi.exe.config 或其他方式以支持 C# 8.0 ?

最佳答案

更新 2020-11-25
它在 Visual Studio 16.8.2 中工作。
只需输入 #reset core切换到 .NET Core。

更新 2020-07-14
根据 https://github.com/dotnet/roslyn/pull/45046 ,它可能会在下一个版本的 Visual Studio 2019 中工作。

Adds a new option to #reset command that allows the user to switch Interactive Window host to .NET Core:

  • #reset 32 - switches to .NET Framework 32-bit process
  • #reset 64 - switches to .NET Framework 64-bit process
  • #reset core - switches to .NET Core 64-bit process

Leaves the default to .NET Framework 64-bit for now.



原答案
目前好像没有办法。因为 C# Interactive 无法运行 Core CLR。

The Interactive Window only supports .NET Framework at this point.Hence features are limited to C# 7.3 and lower. Too enable C# 8 wewould need to first enable running on Core CLR (see #4788).


https://github.com/dotnet/roslyn/issues/40341

关于c# - 如何为 csi.exe 设置 C# 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60946159/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com