6313 Microsoft unveils C# 11 list patterns, raw string literals

Microsoft unveils C# 11 list patterns, raw string literals

C# 11, the planned next generation of Microsoft’s object-oriented language for .NET software development, is beginning to take shape, with new capabilities including list patterns and raw string literals.

Preview features for C# 11 can be found in Visual Studio 2022 17.1 and .NET SDK 6.0.200, and raw string literals in a preview of Visual Studio 2022 17.2. C# 11’s list patterns let developers match against lists and arrays. Developers can match elements and include a slice pattern that matches zero or more elements. With slice patterns, developers can discard or capture zero or more elements.

[ Also on InfoWorld: Programming the Windows kernel with eBPF ]

Raw string literals let developers convert a normal or verbatim string literal to a raw string literal. This new form of string literal starts with a minimum of three """ characters (but no maximum), followed optionally by a new_line and the content of the string, and then ends with the same number of quotes that started the literal.

If C# 11 follows the pattern of its predecessor C# 10, which was released in November as part of .NET 6, then C# 11 would arrive this November as part of .NET 7. Also in C# 11, parameter null checking would provide a simplified syntax for validating that method arguments are not null and throwing ArgumentNullException appropriately. Another change eyed for C# 11 would be allowing newlines in the “holes” of interpolated strings. This programming improvement would make legal a situation that currently would result in a compiler error in C# 10.

Microsoft is listing proposals for future C# features in the CSharpLang repo. The company also provides a language feature status page in GitHub. Developers are encouraged to check out the C# 11 preview features either through Visual Studio or in the latest .NET SDK and setting the LangVersion to Preview.

See also  Devops salaries continued to rise during the pandemic
On this topic: ( from category Software )

Leave feedback

Your email address will not be published.


twenty − sixteen =