【发布时间】:2020-08-05 14:58:15
【问题描述】:
所以我正在查看以下示例 (http://zetcode.com/lang/csharp/arrays/),标题为“c# array slices”。当我在 Microsoft Visual Studio 中复制并粘贴以下示例时:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace s_Sandbox
{
class Program
{
static void Main(string[] args)
{
int[] array = new int[] { 1, 2, 3, 4, 5 };
array[1..2];
}
}
}
[1..2] 下有一个红色下划线,我得到一个Syntax error, "," expected ...这是为什么?我错过了什么?
【问题讨论】:
-
从 c# 8 开始支持此功能
-
@Steve 没有回答我收到错误的原因;而是另一种解决方案。
-
@Homungus 我已经查看了我的解决方案的属性设置,我正在使用 .NET Framework 4.5.2...不过这应该不是问题吗?
-
看这里如何使用 c# 8.0 和 asp.net 项目:stackoverflow.com/questions/56651472/…