As of now me and you might have seen a lot of blog posts, articles, StackOverflow Documentation and from many other sources about the new/proposed features of C# 7.0 since the announcement in Aug 2016. I’m not going to write about the same as some are finalized but more these features are still under discussion with C# design teams.
In this blogs post I’m going to address how to start hands on with new C# 7.0 feature rolled out with Preview release.
If you have VS2017 RC installed on you machine then make sure you have installed the .Net core and Asp.net core tooling. If not you can again launch the setup and choose those module to install.
Now to quickly get started You can download the sample from Code.Msdn.Microsoft.com. This sample have all the feature well documented and a sample project which you can start with for hands on excercise.
Now since I have this project downloaded so when I’m opening it with VS2017 RC and trying to build it getting error:
After update try to build again. Unfortunately I wasn’t able to build it on my machine and got below error similar to the previous one.
Now in order to get things working go to New Project in the same solution and Create a new .Net core console app.
Restore the Nuget package for System.ValueTuple v 4.3.0 version in the newly created project:
Now after installing the package go to the Program.cs file which isn’t in the project so If you try to add it in the ConsoleApp it will throw an error that file with same name already exist.
But it’s not there, Possibly hidden. So you can click on top corner option of SolutionExplorer to show Hidden files.
Now Right click on the Program.cs and select Include the file in the Project. Now that you have the consoleApp ready and Nuget package installed. Now it’s time to add those sample from the solution we downloaded from Code MSDN and get the file in the new project.
Right Click on the Project and Add –> Existing Items… Navigate to the directory where the solution directory is and open the Samples folder, Select all files and “Add as Link”.
After adding the files now open the Program.cs file and copy the content of Program.cs from the sample project or copy below code in your Program.cs
static void Main(string args)
Build the new .Net core console App and run by pressing ‘F5’ and VIOLA!!
Now you can start playing around the new features. Documented in the CodeSample as they are the only features delivered as Preview.