Microsoft is updating its product lines to take advantage of the latest major release of the C# programming language. The company announced C# 8 is included in the release of Visual Studio 2019 Preview 2, and today in the open-source development platform .NET Core 3 Preview 2.
C# 8 features pattern matching for recursive patterns and switch expressions allowing developers to dig deeper into a structure of an object, and provide a lightweight expression of switch statements, the company explained. “C# 8 introduces switch expressions, which enable the following: terser syntax, returns a value since it is an expression, and fully integrated with pattern matching. The switch keyword is “infix”, meaning the keyword sits between the tested value and the list of cases, much like expression lambdas,” Rich Lander, program manager at Microsoft, wrote in a post.
“All of these patterns enable you to write declarative code that captures your intent instead of procedural code that implements tests for it,” Lander wrote. “The compiler becomes responsible for implementing that boring procedural code and is guaranteed to always do it correctly.”
The latest release of the language also enables developers to use declarations in their code instead of using statements requiring them to indent code.
Another major improvement in C# 8 includes async streams. With .NET Core 3.0 Preview 2, developers can now use async streams to develop in Visual Studio 2019 Preview 2 using the latest preview of the C# extension for Visual Studio Code.
.NET Core 3.0 Preview 2 also comes with a number of IEEE floating-point improvements. According to Microsoft, floating point projects are meant to expose required operations so they are compliant with the IEEE spec. Improvements include fixes to parsing and formatting and new Math APIs.
Other features of this release include .NET platform dependent intrinsics, a fast in-box JSON writer & JSON document, GPIO support for Raspberry Pi, and local dotnet tool improvements.
More details are available here.