c# - 错误:未定义或导入预定义类型“System.Range”
问题描述
早些时候我收到了错误:
Feature 'range operator' is not available in C# 7.3. Please use language version 8.0 or greater.
当我升级项目时,以下错误仍然存在:
Predefined type 'System.Range' is not defined or imported
基本上试图测试我们如何检索数组或字符串的片段:
using System;
using System.Windows.Forms;
namespace TestRange
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var story = "Testing C# 8";
Console.WriteLine(story[^6..^0]); // (last 6 chars)
}
}
}
我提到但没有帮助的文章:
https://docs.microsoft.com/en-us/dotnet/api/system.range?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals /csharp-8.0/ranges https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/ranges-indexes
https://www.infoworld.com/article/3532284/how-to-use-indices-and-ranges-in-csharp-80.html
https://www.codejourney.net/2019/02/csharp-8-slicing-indexes-ranges/
一个相关问题:C# 中的数组切片
解决方案
推荐阅读
- javascript - 如何从 asp.net 子表单执行条带支付 html 调用
- hadoop - 多个组作为 HDFS 上的超级用户-Cloudera
- android - listView 适配器中的标题
- reactjs - 如何在反应项目中将 plugin-export-default-from 安装到 Babel
- vb.net - 防止将消息保存在已发送邮件文件夹中
- ios - CMPedometer queryPedometerData() 返回错误的步数
- java - java servlet PrintWriter#flush 停止抛出异常
- visual-studio - Visual Studio 2017 - 测试运行器 - 调试选定的测试 - NUnit - 不工作
- ruby-on-rails - 使用多态方式具有多种地址类型和与模型的关联?
- mongodb - 使用 Spring-Data 进行分页:PageRequest 泄漏到 REST 控制器中