本文介绍了什么是串插在2015年VS最终的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能串插工作。从MS最后的消息我发现了

I can't get string interpolation to work. Last news from MS I found was

http://blogs.msdn.com/b/csharpfaq/archive/2014/11/20/new-features-in-c-6.aspx

然而所有这一切都表示,目前的的工作。任何人都知道,如果串插使它成为2015年VS?是否有任何关于它的文件?可以在一个你举个例子?

However all that is said there is not working. Anyone knows if string interpolation made it into VS 2015? Is there any documentation about it? Can one you give an example?

例如,没有这些格式的工作(的编辑

For instance, none of these formats work (edited):

int i = 42;
var s = "\{i}";  // correction after jon's answer: this works!
var s = $"{i}";  // compiler error
var s = "{{i}}"; // no interpolation

修改关于2015年VS CTP 6 (二○一五年四月二十〇日)

edit about VS 2015 CTP 6 (20.4.2015 )

最后的版本是

var s = $"{i}"

也由目前的ReSharper的版本不支持
ReSharper的9.1.20150408.155143

also supported by the current Resharper version ReSharper 9.1.20150408.155143

推荐答案

您第一种形式的没有的在VS2015 preVIEW工作:

Your first form did work in the VS2015 Preview:

int i = 42;
var s = "\{i}";

这是编译并运行了我。 ReSharper的抱怨,但是这是一个不同的问题。

That compiled and ran for me. ReSharper complained, but that's a different matter.

有关的的最后的C#的发布,它是:

For the final release of C#, it is:

var s = $"{i}";

这篇关于什么是串插在2015年VS最终的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 15:52