C# 7.1 adds the ability to configure the compiler to match a specified version of the language. That enables you to separate the decision to upgrade tools from the decision to upgrade language versions.
C# 7.1 adds the language version selection configuration element, three new language features and new compiler behavior.
The new Feature are :-
- The entry point for an application can have the ASYNC modifier.
- You can use default literal expressions in default value expressions when the target type can be inferred.
- The names of tuple elements can be inferred from tuple initialization in many cases.
Language version selection
The C# compiler supports C# 7.1 starting with Visual Studio 2017 version 15.3, or the .NET Core SDK 2.0. However, the 7.1 features are turned off by default. To enable the 7.1 features, you need to change the language version setting for your project.
- In the Visual Studio, right-click on the project node in Solution Explorer select Properties.
- Select the Build tab and select the Advanced button.
- In the drop down, select C# latest minor version (latest), or the specific version C# 7.1.
- The latest value means you want to use the latest minor version on the current machine.
- The C# 7.1 means that you want to use C# 7.1, even after newer minor versions are released.
Async main :-
static async Task<int> Main()
// This could also be replaced with the body
// DoAsyncWork, including its await expressions:
return await DoAsyncWork();
Default literal expressions
Function<string, bool> where Clause = default;
Inferred tuple element names
int count = 5;
string label = “Colors used in the map”;
var pair = (count, label); // element names are “count” and “label”