Microsoft Reveals Preview C#13 Features
Written by Kay Ewbank   
Monday, 03 June 2024

Microsoft has announced details of what will be included in C# 13. The news was announced at Microsoft's recent Build conference. The new version will have enhanced parameters, extension types, and several features to enhance performance.

The most noticeable change will be that params are no longer limited to arrays. Describing the change, Microsoft says that it's still the case that when the params keyword appears before a parameter, calls to the method can provide a comma delimited list of zero or more values and those values are placed in a collection of the parameter's type.

c

However, starting in C# 13, the params parameter type can be any of the types used with collection expressions, like List<T>, Span<T>, and IEnumerable<T>. You can even use your own collection types if they follow special rules. The ability to use the Span type improves performance because it reduces memory use.

The next change of note is the addition of extension types, though this feature isn't included in the current preview.  Extension methods have been supported since C#3, and can be used to add methods to an underlying type, even if you cannot change its code. C# 13 will add extension types, a new kind of type that supplies extension members for an underlying type, and that are intended for uses such as having an underlying type that you can't change the code of, but you want to make changes. 

Extension types have methods, properties and other members that can be instance or static. Microsoft says there will be two kinds of extension types: implicit and explicit extensions. Implicit extension types apply to all occurrences of the underlying type – in the same way extension methods do today. Explicit extension methods and properties apply only to instances of the underlying type that have been converted to the explicit extension type.

Other improvements to C# 13 will include a lock statement pattern designed to make C# more in line with .NET 9's new dedicated System.Threading.Lock type; and improvements to the method group natural type.

C# is part of the .NET SDK.

c

 

More Information

C# New Features On GitHub

Related Articles

C# 12 Simplifies Syntax

.NET Conf 2023 Was A Blast!

.NET 8 Released 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Student’s Robot Smashes 4x4 Rubik’s Cube World Record
13/06/2025

Matt Pidden, a computer science student at the University of Bristol, UK, has broken the world record for solving a 4x4 Rubik's Cube using a robot he designed, built and trained in just 15 weeks.



GNU Nano 8.5 Enhances Anchor Positions
10/07/2025

GNU Nano 8.5 has been released with improved text anchors and fine-tuned syntax coloring. GNU nano is a command line text editor for Unix and Linux that aims to be simple and easy to use.


More News

pico book

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 03 June 2024 )