11

According to New Features in C# 6, you should be able to declare strings as such:

var name = "world";
WriteLine("hello, \{name}");

For the output:

hello, world

I have created a new Console application, set the Target Framework to .NET Framework 4.6, and I am getting the error "Unrecognized Escape Sequence"

I am using Visual Studio Ultimate 2015 CTP Version 14.0.22512.0 DP

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
Tom
  • 7,640
  • 1
  • 23
  • 47

1 Answers1

19

The string interpolation convention changed. It is now using the "$" operator:

var name = "world";
WriteLine($"hello, {name}");
Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
  • Ah, you're right, that worked. I read they had thoughts of changing it, but couldn't find any documentation on that. Do you happen to have a reference for this? – Tom Feb 16 '15 at 15:58
  • 2
    Yes, [here](http://blogs.msdn.com/b/csharpfaq/archive/2014/11/20/new-features-in-c-6.aspx) – Yuval Itzchakov Feb 16 '15 at 16:05