Jerry Chou
Jerry Chou

Reputation: 322

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

I find a piece of code like this

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

the result is "100.00"

The $ have the same function of string.Format, and I want to know which version of C#.

Upvotes: 5

Views: 9589

Answers (2)

Hari Prasad
Hari Prasad

Reputation: 16986

A C# 6.0 feature, string interpolation.

Upvotes: 3

Joel Coehoorn
Joel Coehoorn

Reputation: 416149

This is called string interpolation, and it's part of C# 6, which was released in July as part of Visual Studio 2015.

Upvotes: 11

Related Questions