新的C#6.0字符串插值语句don';不编译
我正在尝试实现中的一些功能,但是对于新的字符串插值语法,我没有太多的运气(我已经完成了所有其他工作,至少在这段代码中是这样) 我使用的是Visual Studio 2015 CTP6,我已将其配置为使用.NET 4.6,并已进入构建选项,以确保我指定的是C#6.0。我也有 这是我的密码:新的C#6.0字符串插值语句don';不编译,c#,visual-studio-2015,string-interpolation,c#-6.0,C#,Visual Studio 2015,String Interpolation,C# 6.0,我正在尝试实现中的一些功能,但是对于新的字符串插值语法,我没有太多的运气(我已经完成了所有其他工作,至少在这段代码中是这样) 我使用的是Visual Studio 2015 CTP6,我已将其配置为使用.NET 4.6,并已进入构建选项,以确保我指定的是C#6.0。我也有 这是我的密码: using System; using static System.Math; namespace NewCsharp6Features { public class C6Point {
using System;
using static System.Math;
namespace NewCsharp6Features
{
public class C6Point
{
public int X { get; }
public int Y { get; }
public double Distance => Sqrt(X * X + Y * Y);
public C6Point(int x, int y) { X = x; Y = y; }
public override string ToString()
{
return "(\{X}, \{Y})";
}
}
}
我得到两个编译错误:
CS1009 |无法识别的转义序列
知道我做错了什么吗,这里?您需要用$
public override string ToString()
{
return $"({X}, {Y})";
}
你说得对,这是我的问题。我不知道语法在变。