Your first form did work in the VS2015 Preview:
int i = 42;
var s = "\{i}";
That compiled and ran for me. ReSharper complained, but that’s a different matter.
For the final release of C#, it is:
var s = $"{i}";
More Related Contents:
- How to use the ternary operator inside an interpolated string?
- How to use verbatim strings with interpolation?
- What does the => operator mean in a property?
- What does question mark and dot operator ?. mean in C# 6.0?
- How to enable C# 6.0 feature in Visual Studio 2013?
- C# 6.0 Features Not Working with Visual Studio 2015
- What is the difference between getter-only auto properties and expression body properties?
- What is the purpose of nameof?
- How do I use the C#6 “Using static” feature?
- How do I interpolate strings?
- String Interpolation with format variable
- Await in catch block
- Expression-bodied function members efficiency and performance in C# 6.0
- Automated property with getter only, can be set, why?
- C#6.0 string interpolation localization
- How to implement INotifyPropertyChanged in C# 6.0?
- String Interpolation vs String.Format
- Primary constructors no longer compile in VS2015
- What does the => operator mean in a property or method?
- Long string interpolation lines in C#6
- Is C# 6 ?. (Elvis op) thread safe? If so, how?
- Formatting a string into columns using String Interpolation
- What is the meaning of the planned “private protected” C# access modifier?
- How can I use escape characters with string interpolation in C# 6?
- How to upgrade msbuild to C# 6?
- What benefits does dictionary initializers add over collection initializers?
- C# 6.0 Null Propagation Operator & Property Assignment
- String interpolation in a Razor view?
- Error CS1056: Unexpected character ‘$’ running the msbuild on a tfs continuous integration process
- C# 6.0 Support in Visual Studio 2012