Trying out C# 7.0

C# 7.0 has a number of new features to simplify code and increase performance. A nice new feature is types, which make it easy to have multiple results. Another is pattern matching, which simplifies code that is conditional base on the shape of data.

You can check out these features here: https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/

If you want to try them out yourself, you can download and install Visual Studio 2017 RC which was made public at the Microsoft Connect() event. You can download a free version here: https://www.visualstudio.com/vs/visual-studio-2017-rc/

You will find that some new features are not immediately available. If you are trying out tuples, you will get this message.

error CS8179: Predefined type ‘System.ValueTuple`2’ is not defined or imported

This can be resolved by adding the Nuget package System.ValueTuple.

image

In the previous preview (Visual Studio “15”) it was necessary to add the following conditional compilation symbols to your project: __DEMO__ and __DEMO_EXPERIMENTAL__. But this is no longer necessary in Visual Studio 2017 RC.