Did you download the new Visual Studio 2015 IDE? If not, try the preview version before it actually releases and start improving your coding skills with the forthcoming IDE from Microsoft. Today we are going to explore another new feature of C# 6.0 coming with this release.


Let’s continue the series “What’s new in C# 6.0?” and show you what’s coming with C# 6.0 in terms of string interpolation/string concatenation.



Don’t forget to read my previous post on this series: “What’s new in C# 6.0? - Setting default values to Auto Properties”.


String concatenation – we regularly use it to show different records to the user. To do this, we either use the ‘+’ symbol or the string.Format method to format and organize various strings. This now becomes old days mechanism.


Old ways of string concatenation (www.kunal-chowdhury.com)

In C# 6.0, Microsoft added new feature to accelerate your coding skill. Now you can put expressions directly in the string literal to show the values in a proper formatted manner. You can also easily align or specify different format to your values. Not only this! You can now write conditions within string literals with additional strings as content.


Here are few examples of what we can do now with C# 6.0 in Visual Studio 2015 and .NET 4.6:


What's new in C# 6.0 - String Interpolation (www.kunal-chowdhury.com)

Hope you liked this feature. Microsoft is still working on this to improve a lot in string interpolation/string concatenation to add more easier way to provide conditions in strings. Wish to see them soon in the coming release of Visual Studio 2015.


It’s not the end. More to come on this series. Stay tuned to my blog for updates. Till that time, enjoy reading my other posts. Why don’t you subscribe to my blog’s RSS Feed and Email Newsletter? This will give you immediate update in your inbox. Connect with me over Twitter, Facebook and Google+ to get the updates which I share.


Let's Discuss...