String Formating in c# 6

Formatting the string values are very common during development. We generally use String.Format() method, that replaces each format item in a specified string with the text equivalent values from the objects. While this is a common, sometimes this is confusing and produce error. Because, we need to specific the place holder for each item and then map them with the objects values. We also need to ensure that we are referring the correct object value for individual place holder. String Interpolation in C# 6.0 makes it much easier and clean. Using the new String Interpolation, we can directly refer the values rather specifying the place holders.

In the above code snippet both stringValue1 and stringValue2 return the same values, but String Interpolation makes it look more easier and less error prone. Just think about when you are formatting with multiple properties values with some text just for display, you know where to place which values, rather using some placeholders.