Posts

Showing posts from August, 2017

C# 7.1 New Features

Starting with version 7, C# has moved to smaller set of changes being released more frequently. Version 7.1 introduces 3 new features, which are described below. You will need Visual Studio 2017 15.3 or later. In addition, you will need to specify the C# version in the project. To modify the C# version for a project, go to the project properties, then click advanced in the build tab, from there-- you can select a specific version or select latest minor version . async Main The biggest change in C# 7.1 is the addition of async Main method. Main is the entry point to c# console app. The main method must be static, return int or void, and it does not need to be public. If we wanted to have an async starting point we would have to write a helper method. static void Main(string[] args) => MainAsync(args).GetAwaiter().GetResult(); static async Task MainAsync(string[] args) { await DoWork(); } Now we can mark the main method as async. static async Task Main(string[] args) {