Microsoft Previews C# 11 Features in Latest Visual Studio Update

In Microsoft’s Visual Studio 17.1, users will get a preview of C# 11 features. These features will also be available in .NET SDK 6.0.200.

A preview feature is the setting null verification, which checks at runtime if a null was passed to the code. This is distinct from nullable reference types (NRTs), which identify at design time whether a null value is possible.

Another one new addition to the language is the ability to allow line breaks in gaps in non-text interpolated strings. Holes, or interpolation expressions, are contained inside braces and provide runtime values. Previously, newlines were allowed in textually interpolated strings, but in non-textual strings, escapes, such as r or n, were required instead.

C# 11 will also include list templates, which allows developers to match items with lists and arrays. Additionally, developers will be able to include a slice pattern to match zero or more items. List patterns work with countable or indexable types, while slice patterns work with countable or countable types.

Microsoft recommends users play around with these preview features and submit their feedback in the C# repository on GitHub.

Comments are closed.