C# 13: Extended params for Method Parameters
Introduction
.NET 9 and C# 13 are now rolling out and once again, Microsoft has made subtle yet powerful improvements to the language. One of my favorite features is the enhancement of the params
modifier. Up until now, params
was limited to arrays. You could pass a variable number of arguments into a method, but internally they were always treated as an array. That was fine… until it wasn’t. You couldn’t use spans, or other collection types like List<T>, without manual conversions or overloads. But guess what? That’s changing! Let’s dive in.
The limitation in C# 12 and before
Here’s a quick reminder of how params
worked: To use it with a List<int> or a Span<int>? You were stuck with either converting to an array or not using params
at all:
What’s new in C# 13?
Starting with C# 13, you can now use the params
modifier with a wider variety of collection types! This includes:
- Span<T>
- ReadOnlySpan<T>
- Any type that implements IEnumerable<T> and has an Add method
Here’s what it looks like in practice:
No need to allocate an array — you can just pass in a span directly. This is great for high-performance code, or just avoiding extra work.
This isn’t limited to built-in types. If you have your own collection class that meets the criteria (implements IEnumerable<T> and has an Add(T) method), you can use it too:
For many devs, this won’t change day-to-day life dramatically. But if you care about performance or API ergonomics, this is a welcome enhancement. You can now write cleaner, more efficient methods that accept flexible input — without the boilerplate. It’s also a sign that C# continues to evolve in thoughtful ways. We’re not just getting flashy new features; we’re getting real polish that improves how we write and maintain code.
Hope you will like it! 🙂