Since Microsoft has been launched C#8.0 on September 2019. Net Core 3 go with Visual Studio 2019 (Windows Ver. 16.3 / Mac Ver. 8.3 or higher) enable us enjoy the new syntax goodies of those features inside our application.
Main features:
- Readonly members
- Default interface methods
- Pattern matching enhancements
- Using declarations
- Static local functions
- Disposable ref structs
- Nullable reference types
- Asynchronous streams
- Indices and ranges
- Null-coalescing assignment
- Unmanaged constructed types
- Stackalloc in nested expressions
- Enhancement of interpolated verbatim strings
Turn-up setting support for C#8.0
Open your project .csproj file and added the below tag: LangVersion
<PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion></PropertyGroup>
Summary
We are not going to go through detail of each features but we would like to note down when will we use those features😊, if you got curious how to adapt its into your application, please see official site for more examples.
Closing
So far I have not used all of those features in my application yet. But with the glance over the main features of C# 8.0 that really excited me. Not only the syntax sugar that language provide to us, some of syntax indeed offering us more productivity code style and made our code base more readable and clean😁. If you got the chance, I suggested you to give it a try and enjoy the powerful of .Net Core that brought to us.
Reference