Paul Krill
Editor at Large

C# 13 enhances params, introduces extension types

news
May 21, 20242 mins
C#Development Libraries and FrameworksMicrosoft .NET

Forthcoming update to the C# language extends params parameter support and introduces a new type that supplies extension members for an underlying type.

C# 13, a planned update to Microsoft’s popular general purpose language for .NET development, is set to enhance params parameters to give developers more flexibility, and to introduce extension types, a new kind of type that provides extension members for an underlying type.

Microsoft detailed the plans for C# 13 on May 21.

Beginning with C# 13, the params parameter type can be any of the types used with collection expressions such as Span<T>, List<T>, and IEnumerable<T>. Developers also can use their own collections if they follow special rules. Also, many methods of the .NET Runtime are being updated to accept params Span<T>, to reduce memory allocations and enable applications to run faster. This is part of an ongoing effort to make C# faster and more reliable. It also is an example of attention given to ensuring various C# features work well together, Microsoft said.

Extension types are a new kind of type that supplies extension members for an underlying type. Extension types have methods, properties, and other members that can be instance or static. Extension types allow developers to simplify the code that provides important work in an application, Microsoft said, by supplying and organizing extensions that customize specific instances of the underlying objects.

The new C# features can be tried in the .NET 9 Preview SDK or the latest Visual Studio 2022 IDE. Other improvements planned for C# 13 include field access in auto-properties and a revamped approach to breaking changes to ensure cleaner language evolution over the coming years.

Usually, official releases of C# occur alongside updates to .NET in November. C# 13 follows C# 12, which arrived in November 2023, featuring primary constructors and collection expressions. C# ranked as the fifth and fourth most popular programming language respectively in the Tiobe index and the Pypl index for this month.