2 min

Tags in this article


Visual Studio 17.1 offers users a sneak peek at C# 11 features

Microsoft’s Visual Studio 17.1, users will get a sneak peek at features coming to C# 11. These features will also be available in .NET SDK 6.0.200. 

One new addition to the language is the ability to allow newlines in holes in non-verbatim interpolated strings. Holes, or interpolation expressions, are contained inside curly braces and supply runtime values. Previously newlines were allowed in verbatim interpolated strings, but in non-verbatim strings escapes, like \r or \n, were required instead.  

C# 11 will also include list patterns, which allows developers to match elements against lists and arrays. In addition, developers will be able to include a slice pattern to match zero or more elements. List patterns work with types that are countable or indexable, while slice patterns work with types that are countable or sliceable. 

Another new feature available in early preview is parameter null checking, which verifies at runtime if a null has been passed to code. This is separate from Nullable Reference Types (NRT), which identifies at design time if a null is possible.

“Designing and developing in the open”

Kathleen Dollard, Principal Program Manager for .NET, described the new C#11 features in a blog post. There, she “distills” the new C# features for easy consumption. “We love designing and developing in the open! You can find proposals for future C# features and notes from language design meetings in the CSharpLang repo. The main page explains our design process and you can listen to Mads Torgersen on the .NET Community Runtime and Languages Standup where he talks about the design process.”

Visual Studio 17.1 and .NET SDK 6.0.200 offer an early peek into C# 11. “You can play with parameter null-checking, list patterns, and new lines within curly braces (the holes) of interpolated strings,” Dollard writes.

“We hope you’ll check out the C# 11 Preview features by updating Visual Studio or downloading the latest .NET SDK, and then setting the LangVersion to preview.”