String interpolation - C# 6 Language New features

After releasing C# 6 Microsoft deprecate the syntax of some old features. Today I am going to share one new feature named "String Interpolation".

String Interpolation is the kind of string concatenation (not exactly).Itis the process of evaluating a string literal containing one or more placeholders, yielding a result in which the placeholders are replaced with their corresponding values.

String interpolation exists from the first release of C#. We are performing string interpolation using+ operator or string.Format function to produce a resultant string. This new feature is definitely going to save your time and make your code more readable. Before few weeks Microsoft refurnished the syntax of string interpolation (hope they will not change it again). Instead of using \{} at placeholder simple put "$" as prefix in the string.

Now, we are going to discuss string interpolation with two examples. Notice yourself how new feature is going to help you.

The first way is most common, we concatenate the strings using + operator. Sometime this method takes more time to set output string. In second way we use better and smarter approach. We use String.Format which is more readable than the first way. You can learn more about String.Format and how to generate different kind of output from here.