In a blog post, Microsoft says it has been developing C# 8.0 while simultaneously released versions 7.1, 7.2, and 7.3. The company says more details about features will arrive when Visual Studio 2019 previews drop. In the meantime, Microsoft has touched on some of the main changes coming in C# 8.0.
Leading the way is the introduction of Nullable reference types. Microsoft says this feature will mitigate null reference exceptions which has been a problem in programming for decades:
“It stops you from putting null into ordinary reference types such as string – it makes those types non-nullable! It does so gently, with warnings, not errors. But on existing code there will be new warnings, so you have to opt in to using the feature.”
Of course, in some instances programmers may want to null in C# 8.0. If so, users can write a nullable reference type.
Microsoft will also make tweaks to Async, a feature first revealed with C# 5.0. However, it was limited as it was not as useful when creating continuous streams. In C# 8.0, Microsoft is launching Async streams:
“We introduce IAsyncEnumerable
More New Features
The new abilities coming to C# continue with a new type of index that allows programmers to create an index from an int that starts from the beginning. Furthermore, a new Range type of two indexes is also coming, one for the start and the other for the end. An important new feature in version 8.0 is Recursive Patterns, which allow users to put patterns within patterns. Switch Expressions, which allow users to switch statements with patterns are getting an improvement as Microsoft says they are difficult to write in C# 7.0. In the upcoming update, the company will make switch expressions “lightweight”.