Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New C# 6.0 String Interpolation statements don't compile [duplicate]

I am trying to implement some of the features in this video but I'm not having much luck with the new String Interpolation syntax (I have everything else working, at least that's in this code).

I am using Visual Studio 2015 CTP6, I have configured it to use .NET 4.6 and have gone into the Build options to make sure I was specifying C# 6.0. I have also followed the instructions here.

Here is my code:

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})";
        }
    }
}

I am getting two of this compilation error:

CS1009 | Unrecognized escape sequence

Any idea what I'm doing wrong, here?

like image 757
Jaxidian Avatar asked Mar 19 '15 20:03

Jaxidian


People also ask

How much is the latest Benz 2022?

The 2022 C-Class sedan starts at $43,550. The midtier Exclusive model starts at $45,800, and the top Pinnacle trim has a starting MSRP of $47,500. All-wheel drive is available in all models for an additional $2,000.

Is the C class a good car?

Mercedes-Benz's entry-level sports sedan has been thoroughly redesigned for the 2022 model year but the C-class sticks with its winning formula of luxury and prestige at an affordable price. The modernization gives the C-class what it needs to better battle rivals such as the Audi A4, BMW 3-series, and Genesis G70.

Is Benz C180 a good car?

A super duper car with full of comfort with excellent steering. The Mercedes benz ranks 4 out of 20 in luxury cars.

Is there a C180 AMG?

Mercedes-Benz C Class C180 AMG Line 4dr Auto Reviews 2022 | Top Gear.


1 Answers

You need to proceed the string with a $

        public override string ToString()
        {
            return $"({X}, {Y})";
        }
like image 92
Petrus Prinsloo Avatar answered Nov 15 '22 13:11

Petrus Prinsloo