Code -> Break -> Fix -> Blog

C# 6.0 : String Interpolation


Using String.Format() can be error-prone and difficult to handle if we have lot of place holders, like,

Console.WriteLine(String.Format("{0} {1} {2}", firstName, middleName, lastName));

It will be helpful if we can eliminate the place-holders and use the values in-place.

This is possible with C# 6.0:

Console.WriteLine("\{firstName} \{middleName} \{lastName}");

The above code will in-turn call the String.Format() and do the needful.

This makes the developer’s life simple.

Let me know your thoughts.


Twitter Logo


2 thoughts on “C# 6.0 : String Interpolation

  1. Pingback: C# 6.0 : Function & Property with Lambda expression (Expression Body) | Bhavya

  2. Pingback: New Features of C# 6.0 | Bhavya

Leave a Reply

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

You are commenting using your 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