Getting started with C# 6.0

Posted: November 17, 2014 in Uncategorized

Getting started with C# 6.0 :

I have just installed Visual Studio 2015 and was playing with C# 6.0. Has loads of new features supported out of the box which are mainly for making the code clean and lean.

Some of the features supported by C# 6.0 are already listed in the below link :

I tried to run a sample application which uses some of the new features and found it very interesting.

Null checks using ?. operator (also called as Elvis operator) and String.Format using \{} (also called as String interpolation) and loads of such things are supported by the Framework out of the box.

Here is a sample code which can get you started :

using System.Console;

namespace VS2015Sample


class Program


   static void Main(string[] args)


      string version = “Dotnet 4.6”;

      object vsEditor = null;

      WriteLine(“Sample executing with VS 2015 on \{version} \{vsEditor?.ToString()}”);

      vsEditor = “VS 2015”;

      WriteLine(“Sample executing with VS 2015 on \{version} \{vsEditor?.ToString()}”);





If you see the above code, I am not using Console.WriteLine or Console.ReadLine anywhere. I am also not having null checks for displaying the vsEditor details. Also, String.Format is not used anywhere for formatting display strings.

Output of the above code will be as depicted below:


C# 6.0 looks promising and will help developer fraternity with a lot of simple tricks.

Happy coding!


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