哪个版本的 C# 使用 $ 而不是 string.format

which version of C# to use $ instead of string.format

我找到一段这样的代码

int a = 100;
string str = $"{a:0.00}";
Console.WriteLine(str);

结果是“100.00”

$和string.Format功能一样,想知道是哪个版本的C#

这称为 string interpolation,它是 C# 6 的一部分,它于 7 月作为 Visual Studio 2015 的一部分发布。

一个C# 6.0特征,string interpolation