String.format is so old school

String.format is so old school

All my dev life I have used string.format("TEXT {0} MORE TEXT",variableValue) to add variable values into a string, but the other day I found the $ feature, which arrived in C# 6.

How you use string.format

var age = 64
String.format("my am {0} old today",age)

Using String interpolation $

This new way of doing string formatting must easier and quicker. You simple write the text add the variable in the middle and there you go. You don't need to make sure you have the correct location etc.

var age = 64;
$"my am {age} old today";

More Info