[#VS2015] String Interpolation vs String.Format (your team will love you)


I was trying to use Visual Studio 2015 as my main development IDE for a while. The new versions are more stable, so I use it more and more and I’ve not opened Visual Studio 2013 for a while.

One of the best features in VS2015 is Roslyn as main compiler for .Net. This opens a new world of possibilities for writing code in a more elegant way. One of these options is the ability to use String Interpolation instead of the classic String.Format () .

If anyone would not read the Wikipedia link or study a little, maybe it is best see the following lines of code

using System;
namespace ConsoleApplication1
class Program
static void Main(string[] args)
string name = "Valentino";
int age = 7;
var data1 = string.Format("name:{0}, age:{1}", name, age);
Console.WriteLine("classic string format – {0}", data1);
var data2 = $"name:{name}, age:{age}";
Console.WriteLine("string interpolation – {0}", data2);

view raw
hosted with ❤ by GitHub

Note: if did not know it the ability to use String Interpolation was in the Top 10 of the most requested features to the new version of Visual Studio (link)

As the saying goes for taste colors. To my personally I like this format to work with Strings. And I believe that the recommendation of use is very clear…

Do not use String Interpolation if you are sharing code with a team where there are people who use Visual Studio 2013.

You can also find with wonders like this


Saludos @ Madrid

/El Bruno


Roslyn, https://github.com/dotnet/roslyn

String Interpolation, http://en.wikipedia.org/wiki/String_interpolation

String Interpolation User Voice, http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2312991-string-interpolations-in-c

4 thoughts on “[#VS2015] String Interpolation vs String.Format (your team will love you)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.